in reply to Sorting a hash by values...

You can also do the sorting and printing in one fell swoop using sort and map like this

print map {qq{$_ is $age{$_} years old\n}} sort {$age{$b} <=> $age{$a}} keys %age;

I hope this is of use.

Cheers,

JohnGG

Update: Added missing closing brace in map, thanks Hue-Bond. That's what comes of hasty posting after too much beer :(

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

    Wow... That 'map' is sexy. I need to go read up on that more. Thanks!