Given an array, I would like to get an array holding the indices of the permutation that would result in the array being sorted. An example should make it clear: Input array:
[10, 50, 40, 20, 30]
should produce the following output:
[0, 3, 4, 2, 1]
because if I first take the 0th, then the 3rd, then the 4th, then the 2nd and then the 1st element of the list, I would get [10, 20, 30, 40, 50]
, which would be the sorted array.
Of course I could just code it in Python from scratch, but I wonder if there is a function for this in Python already.