my %hash; $hash{$_}++ foreach (@array); print "$_: $hash{$_} " foreach (sort {$hash{$a} <=> $hash{$b}} keys %hash);