C:\test>perl -E"say join ' ', int( rand 20 ), sort{ $a<=>$b } int( rand 1.2e6 ), int( rand 1.2e6 ) for 1 .. 1e6" | sort | perl -nle"if($last eq $_){ ++$n }else{ print qq[$last : $n];$n=1} $last=$_" | wc -l 999978