This short bit of (golfed/terse) Perl seems to be 2-3x faster for the inputs I tested. Though it's also 2x more "code", despite golfing and skipping best practice strict/warnings. And both are wasting some time sorting the whole list versus a partial heap sort or similar.
#!/usr/bin/perl
$l=shift(@ARGV)||1;
while (<>) {
for (split) {
$c{lc($_)}++;
}
}
for (sort { $c{$b} <=> $c{$a} } (keys %c)) {
print "$c{$_} $_\n";
last if ++$i == $l;
}