convenientstore has asked for the wisdom of the Perl Monks concerning the following question:
But not sure about hash as below method does not work.@count_s = sort { $reportn{$a} <=> $reportn{$b}; } @count_s; foreach (@count_s[0..4]) { print "$_ ====> $reportn{$_}\n"; }
foreach my $hero ( sort keys %total_o) { if ($reportn_o{$hero}) { @reportnL = sort { $total_o{$a} <=> $total_o{$b} } values (%t +otal_o{$hero}); } } for (@reportnL[0..4]) { print "$_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sort hash by value
by salva (Canon) on Dec 02, 2007 at 19:55 UTC | |
|
Re: sort hash by value
by moritz (Cardinal) on Dec 02, 2007 at 18:01 UTC | |
|
Re: sort hash by value
by grep (Monsignor) on Dec 02, 2007 at 18:11 UTC | |
|
Re: sort hash by value
by johngg (Canon) on Dec 02, 2007 at 18:44 UTC |