in reply to Comparing all keys in a hash

Is your
return @k2 - @k2 if @k1 <=> @k2;
an artifact of optimization? Or is this part of your definition of comparing the keys of two hashes?