Skip to content

Instantly share code, notes, and snippets.

@hmkz
Created December 24, 2013 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hmkz/8107759 to your computer and use it in GitHub Desktop.
Save hmkz/8107759 to your computer and use it in GitHub Desktop.
標準入力から重複した行を計算して出力する。
#!/usr/bin/env python
import sys
tmp = {}
for line in sys.stdin:
line = line.strip()
if line not in tmp:
tmp[line] = 0
else:
tmp[line] += 1
for k,v in sorted(tmp.items(), key=lambda x:x[1]):
print k, v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment