summaryrefslogtreecommitdiff
path: root/hist-tok
blob: b81604f5738db19c1f6816c4d712c65c928a9d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env ruby

counts = {}
counts.default = 0
while line = STDIN.gets
  toks = line.strip.split
  toks.each { |tok|
    counts[tok] += 1
  }
end

sorted = []
counts.each_pair { |k,v|
  sorted << [k,v]
}

sorted.sort_by! { |i|
  -i[1]
}

sorted.each { |i|
  puts "#{i[0]}\t#{i[1]}"
}