in reply to Frequency of words in text file and hashes

As others already explained, sort is your friend. You could, however, improve your code by:

assuming that case doesn't matter and words are defined by </code>\w+</code>, this code should work:

my %count; while ( <FILE> ) { $count{lc $_}++ for /\w+/g; } print "$_ => $count{$_}\n" for sort { $count{$b} <=> $count{$a} || $a cmp $b} keys %count;
(notice the extra sort for equal ranking words)

HTH,
Paul