Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: sort hash by value

by sulfericacid (Deacon)
on Mar 20, 2006 at 01:00 UTC ( #537850=note: print w/replies, xml ) Need Help??


in reply to sort hash by value

Hi Anonyous Monk.

You almost had it. You need to wrap the sort in {} and the hash in parenthsis.

foreach (sort {$hash{$a} cmp $hash{$b}} (keys %hash)


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://537850]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2018-06-25 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?