Skip to content

Instantly share code, notes, and snippets.

@solidpple
Created March 23, 2018 01:27
Show Gist options
  • Save solidpple/30dcc8fed8536d635df46fa107b13952 to your computer and use it in GitHub Desktop.
Save solidpple/30dcc8fed8536d635df46fa107b13952 to your computer and use it in GitHub Desktop.
import heapq
topK = 10
item_score_dict = {'1': 3,'2':2,'3':5,'4':1, '8':3}
ranklist = heapq.nlargest(topK, item_score_dict, key=item_score_dict.get)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment