Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: max "value " of an hash

by k_manimuthu (Monk)
on Dec 21, 2010 at 12:01 UTC ( #878234=note: print w/ replies, xml ) Need Help??


in reply to Re^3: max "value " of an hash
in thread max "value " of an hash

Hi Khariton,

Yes you are right, for my previous node I just show how to get the maximum value in a hash. Now, I had updated the code, that will get the maximum value, as well as the corresponding keys.

# get values with numerical sort @values = sort {$a<=>$b} values %hash; # process each element foreach (keys %hash) { # get the key name of the maximum value print "\nkey : $_ : value $hash{$_}" if ($values[$#values] == $has +h{$_}); }


Comment on Re^4: max "value " of an hash
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-12-28 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls