See japhy's message, particularly the ASCIIbetically sorted by value example. It shouldn't be hard for you at all to modify my example subroutine to account for the differences.

You appear to be getting hung up on the notion that hashes themselves can be ordered, which just isn't the case: if you want a hash to be ordered in any fashion, you have to order it yourself with sort.

If you want to pass around a new ordering, a better option would be to create an array of the keys in the order of your sorted values (ie, my @keys_of_sorted_values = sort { $tobesorted{$a} <=> $tobesorted{$b} } keys %tobesorted;) and then pass that around with your hash by reference.

You don't seem to be understanding the chief issue here, Wil. Hashes CAN NOT be sorted. There is no such thing in Perl as a sorted hash -- the ONLY thing you can do is iterate over the keys in a specific order. Example:

The first sorted list of keys is the keys in ASCIIbetical order. The second sorted list of keys is the keys based on the VALUES in ASCIIbetical order. Notice: J, h, m, o, in the first list (the starting letters of the KEYS) vs. J, h, t, y, in the second list (the starting letters of the VALUES).