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;