kettle has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use warnings; my %some_hash = ( sunny => .63, cloudy => .17, rainy => .2 ); my ($max) = sort {$some_hash{$b}<=>$some_hash{$a}} keys %some_hash; print $max." :: ".$some_hash{$max}."\n"; outputs: sunny :: 0.63
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: max key-value pair in a hash
by gaal (Parson) on Mar 27, 2006 at 05:36 UTC | |
|
Re: max key-value pair in a hash
by CountZero (Bishop) on Mar 27, 2006 at 05:44 UTC | |
by jdporter (Paladin) on Mar 27, 2006 at 15:01 UTC | |
|
Re: max key-value pair in a hash
by BrowserUk (Patriarch) on Mar 27, 2006 at 06:03 UTC | |
by kettle (Beadle) on Mar 27, 2006 at 06:26 UTC | |
by BrowserUk (Patriarch) on Mar 27, 2006 at 06:39 UTC |