python argsort list code example
Example 1: python argsort a list
a=list((1, 2, 3, -20))
sorted(range(len(a)), key=a.__getitem__)
output:
[3, 0, 1, 2]
Example 2: python argsort
def g(seq):
# http://stackoverflow.com/questions/3382352/equivalent-of-numpy-argsort-in-basic-python/3383106#3383106
#lambda version by Tony Veijalainen
return [x for x,y in sorted(enumerate(seq), key = lambda x: x[1])]