Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: printing largest hash value

by demerphq (Chancellor)
on Feb 22, 2005 at 09:06 UTC ( [id://433288]=note: print w/replies, xml ) Need Help??


in reply to printing largest hash value

my %hash=(); my $highest; my @highest=grep {defined $highest ? $hash{$_}==$highest : (($highest= +$hash{$_}),1) } sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash;

or

my %hash=(); my %rev; my $highest=0; for (keys %hash) { $rev{$hash{$_}}{$_}++; $highest=$hash{$_} if $highest < $hash{$_}; } print sort keys %{$rev{$highest}};
---
demerphq

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-23 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found