Skip to content

Instantly share code, notes, and snippets.

@volf52
Created September 5, 2017 08:32
Show Gist options
  • Save volf52/fb784873cd71edb4152b1f8f302d3339 to your computer and use it in GitHub Desktop.
Save volf52/fb784873cd71edb4152b1f8f302d3339 to your computer and use it in GitHub Desktop.
Ranking a data set
def ranking(arr):
cp = []
for x in arr:
if cp.count(x) == 0:
cp.append(x)
cp.sort()
ranks = {x:y for x,y in zip(cp, range(1, len(cp)+1))}
return [ranks[x] for x in arr]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment