Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: sort hash by value

by grep (Monsignor)
on Dec 02, 2007 at 18:11 UTC ( #654435=note: print w/ replies, xml ) Need Help??


in reply to sort hash by value

I'm not quite sure what your doing with all that code, there seem to be quite a few mistakes. Which makes it hard for me to follow.

But as to your main point of the sort not working: You're sending in the values but treating them like keys and trying to do a lookup.
@reportnL = sort { $total_o{$a} <=> $total_o{$b} } values (%total_o{$hero});

Change it to
@reportnL = sort { $total_o{$a} <=> $total_o{$b} } keys %total_o ;

UPDATE: Just noticed his was my 500th post.

grep
One dead unjugged rabbit fish later...


Comment on Re: sort hash by value
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-07-11 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (224 votes), past polls