On Wednesday 20 December 2006 18:02, Tom Denniston wrote: > If you want the n largest item i would recommend quicksort ... > I don't know of a way to do this in numpy. I think it would require > adding a cfunction to numpy. Perhaps an "argnth" function? > > Does anyone else know of an existing mechanism?
Is it really needed when you have argsort ? >>> x=N.array([1,3,5,2,4]) >>> ax=N.argsort(x) >>> ax array([0, 3, 1, 4, 2]) >>> x[ax[0]], x[ax[-1]], x[ax-3]] 1, 5, 3 Or am I once again missing the point entirely ? _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion