Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Sorting hash of hashes by values

by tangent (Curate)
on Nov 15, 2013 at 23:12 UTC ( #1062820=note: print w/ replies, xml ) Need Help??


in reply to Sorting hash of hashes by values

You're almost there, just change the print statement to:

print "$value -> $key\n";
If all of the values are numeric you should change the comparison operator to <=> like so:
foreach my $key (sort { $HoH{0}{$a} <=> $HoH{0}{$b} } keys %{$HoH{0}} +) { my $value = $HoH{0}{$key}; print "$value -> $key\n"; }


Comment on Re: Sorting hash of hashes by values
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062820]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (15)
As of 2015-07-07 17:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls