Skip to content

Instantly share code, notes, and snippets.

@kronos
Created March 20, 2011 23:32
Show Gist options
  • Save kronos/878785 to your computer and use it in GitHub Desktop.
Save kronos/878785 to your computer and use it in GitHub Desktop.
import std.stdio, std.string;
void main()
{
uint[string] freqs;
foreach(line; stdin.byLine())
{
foreach(word; split(strip(line)))
{
++freqs[word.idup];
}
}
sort! ((a, b) { return freqs[a] > freqs[b]; }) (words) ;
foreach(key, value; freqs)
{
writefln("%6u\t%s", value, key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment