in reply to Sort: By keys, values, and their returning values.

Close, but no cigar:

sort { $hash{$a} <=> $hash{$b} } values %hash;

This is taking an array of hash values (returned by values %hash, and treating them as keys. And unless your values are also available as keys ( i.e. my %hash = ( key1 => 'key2', key2 => 'key1',); ) it will not give you the answer you are hoping for!

The best approach is to keep it simple:

# list of sorted keys in numeric order my @keys = sort { $a <=> $b } keys %hash; # list of values in numeric order my @values = sort { $a <=> $b } values %hash; # a list of the *keys* sorted by their corresponding value my @keys_by_value = sort { $hash{$a} <=> $hash{$b} } keys %hash;

Hope this makes things clearer!? Also remember their is plenty of other references out there on perldoc:

    keys
    values
    sort
Good hunting!

Just a something something...