foreach $key (sort byValue keys %myHash) { print "$key - $myHash{$key}\n"; } sub byValue {$myHash{$a} cmp $myHash{$b}};