in reply to sorting hashes
use (primary test) || (secondary test) in your sort block:
my %hash = ( A => 91, B => 82, C => 1, D=> 44, E => 82 ); my @by_value = sort { $hash{$a} <=> $hash{$b} || $a cmp $b } keys %hash; print "$_ => $hash{$_}\n" for @by_value;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting hashes
by pdr_dan (Initiate) on Oct 17, 2007 at 20:09 UTC |