use strict; use warnings; my %hash; while () { chomp; $hash{$_}++ for (split); } print "ALPHABETIC\n"; print "$_ $hash{$_}\n" for (sort keys %hash); print "\nBY NUMBER\n"; print "$_ $hash{$_}\n" for (sort {$hash{$b} <=> $hash{$a} || $a cmp $b} keys %hash); __DATA__ three blind mice three blind mice see how they run