I\'m sorry in advance if this is a duplicated question, I looked for this information but still couldn\'t find it.
Is it possible to arrange a numpy array (or python
Have you looked at the built-in numpy argsort method?:
argsort
http://docs.scipy.org/doc/numpy/reference/generated/numpy.argsort.html
I can sort an array with 300,000 random floats in about 29 ms on my machine using that method.
def f(a,N): return np.argsort(a)[::-1][:N]