Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 lurking in the Monastery: (2)
As of 2018-02-25 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (312 votes). Check out past polls.

    Notices?