Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created April 10, 2019 09:46
Show Gist options
  • Save seungjin/59ad2ffb5fa3447d2d53fcfcb61ae707 to your computer and use it in GitHub Desktop.
Save seungjin/59ad2ffb5fa3447d2d53fcfcb61ae707 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
import sys
from operator import itemgetter
from collections import defaultdict
def main():
count = defaultdict(int)
for line in sys.stdin:
for word in line.split():
count[word] += 1
for e, v in sorted(count.items(), key=itemgetter(1), reverse=True):
print e, " ", v
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment