in reply to The strange ordering of hash values

Because hashes are not ordered.
If you were to change the second line to:
@values = sort values(%hash);
..then you might get the output that you expect.