Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Sorting hash of hashes by values

by tangent (Priest)
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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062820]
help
Chatterbox?
[choroba]: Good morning, if a bit rainy
[marto]: life is a struggle :P I'm glad the GPW went well.
[Corion]: Hi choroba! Yeah, I brought the rain with me from Hamburg
[Corion]: marto: As am I ;) And we got two interested locations for next year, Munich and Cologne maybe, which is great as well. Not Berlin though ;)
[marto]: damn

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-06-29 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (655 votes). Check out past polls.