Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
How do you print the key(s) of the largest value in a hash? I have a script that counts the occurences of something and the occurences it the value of that key.
And I need it to determine the greatest value, sort by it and only print the highest keys/value. In this example the highest value is 4 shared by ORANGE and BLUE. I need it so it just prints these two hash elements.Key -> Value red -> 2 pink -> 1 orange -> 4 black -> 3 blue -> 4
Whether it's just one highest value or if X number share it, all the highest valued key/value pairs need to be sorted.
I am very confused at how to do this.
Back to
Seekers of Perl Wisdom