user1276273 - 1 year ago 78

Python Question

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:

[3 2 0 1]

Clearly my understanding of the function is lacking.

Answer Source

According to the documentation

Returns the indices that would sort an array.

`2`

is the index of`0.0`

.`3`

is the index of`0.1`

.`1`

is the index of`1.41`

.`0`

is the index of`1.48`

.