How do you sort, operate on, and then unsort the result?
Assume I have a float array p1 = 0.15,0.3, 0.25, 0.12, .... It is sorted to: p2 = sort(p1
You need a double argsort here to keep the order:
In [6]: a
Out[6]: array([5, 4, 8, 3, 6, 1, 2, 4, 9, 6])
In [7]: b=sort(a)
In [8]: b
Out[8]: array([1, 2, 3, 4, 4, 5, 6, 6, 8, 9])
In [9]: ii=a.argsort().argsort()
In [10]: c=b*b
In [11]: c
Out[11]: array([ 1, 4, 9, 16, 16, 25, 36, 36, 64, 81])
In [12]: c[ii]
Out[12]: array([25, 16, 64, 9, 36, 1, 4, 16, 81, 36])