Why is numpy giving this result:
x = numpy.array([1.48,1.41,0.0,0.1])
print x.argsort()
>[2 3 1 0]
when I\'d expect it to do this:
Just want to directly contrast the OP's original understanding against the actual implementation with code.
numpy.argsort
is defined such that for 1D arrays:
x[x.argsort()] == numpy.sort(x) # this will be an array of True's
The OP originally thought that it was defined such that for 1D arrays:
x == numpy.sort(x)[x.argsort()] # this will not be True
Note: This code doesn't work in the general case (only works for 1D), this answer is purely for illustration purposes.