def MapToRanks(t):
 pairs = enumerate(t)
 sorted_pairs = sorted(pairs, key=itemgetter(1))
 ranked = enumerate(sorted_pairs)
 resorted = sorted(ranked, key=(lambda trip: trip[1][0]))
 ranks = [(trip[0] + 1) for trip in resorted]
 return ranks

def MapToRanks ( t ) : pairs = enumerate ( t ) sorted_pairs = sorted ( pairs , key = itemgetter ( 1 ) ) ranked = enumerate ( sorted_pairs ) resorted = sorted ( ranked , key = ( lambda trip : trip [ 1 ] [ 0 ] ) ) ranks = [ ( trip [ 0 ] + 1 ) for trip in resorted ] return ranks
returns a list of ranks corresponding to the elements in t .