@SortedArrayOfHashes = sort { return $a->{'key1'} cmp $b->{'key1'} or # if these are equal try the comparison below $a->{'key2'} cmp $b->{'key2'} or # if these are equal try below $a->{'key3'} cmp $b->{'key3'} #if these are equal, then we give up; they're the same. } @ArrayOfHashes;