I needed to find a ranking of a large data set. Using Python, it makes sense to look at the numpy library for this.
Numpy has the function argsort, which returns index positions [1]. One would think these are exactly the ranks we are after. Unfortunately, this is not the case.
>>> import numpy as np >>> a = [3.0, 1.0, 5.0, 2.0] >>> indx = np.argsort(a) >>> indx array([1, 3, 0, 2], dtype=int64)