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;
In reply to Re: sorting hashes
by FunkyMonk
in thread sorting hashes
by pdr_dan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |