my @sorted_words = reverse sort { $stats{$a} <=> $stats{$b} } keys %stats; print "$_: $stats{$_}\n" for @sorted_words;