y_rev = np.empty(x.size, dtype=np.int64)
y_rev[x.argsort()] = np.arange(x.size)[::-1]
Transform a set of numbers in numpy so that each number gets converted into a number of other numbers which are less than it