foreach (reverse sort {$hash{$a} <=> $hash{$b} || $a cmp $b} (keys %hash))