I know that this question has been asked a hundred times, but the answer always seems to be \"use numpy\'s argsort\". But either I am misinterpreting what most people are as
The reason why you are not getting the 'right,' or expected, answer is because you are asking the wrong question!
What you are after is the element rank after sort while Numpy's argsort() returns the sorted index list, as documented!. These are not the same thing (as you found out ;) )!