in reply to Sorting a hash by values...

"Ok, I know you can't actually sort a hash.."

Of course you can sort a hash. You can sort a hash anyway you like. What you cannot rely on however, is the unsorted ordering in a hash.

Anyway, back to your problem at hand - all you really need to get your desired output is:

for my $person (sort {$age{$b}<=>$age{$a}} keys %age) { print "$person is $age{$person}\n"; }

There is really no need for the intermediate array, that is just un-necessarily complicating things.

Cheers,
Darren :)

Replies are listed 'Best First'.
Re^2: Sorting a hash by values...
by blueberryCoffee (Scribe) on Oct 09, 2006 at 17:57 UTC
Re^2: Sorting a hash by values...
by chinamox (Scribe) on Oct 10, 2006 at 09:27 UTC

    Thanks Darren! This was very helpful.