Skip to content

Instantly share code, notes, and snippets.

@bigsnarfdude
Created May 4, 2013 07:08
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 bigsnarfdude/5516567 to your computer and use it in GitHub Desktop.
Save bigsnarfdude/5516567 to your computer and use it in GitHub Desktop.
dict processing
data = open('sequence', 'r').readlines()
elements = {}
for line in data:
(user, element, js_time) = line.split("\t")
if element not in elements:
elements[element] = 1
else:
elements[element] += 1
sorted_counted = elements.items()
sorted_counted.sort( key=lambda a:(-a[1],a[0]) )
print sorted_counted[0:10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment