Reputation: 165
In R, given an numeric array, how to produce another array which contains sorted index order into the original array? To clarify my question, consider an example: For an original array:
[33 11 55 22 44]
I want to produce another array:
[3 1 5 2 4]
Each element in the second array indicates sorted index of corresponding element in the first array.
In MATLAB, this can be done by using [B,XI]=sort(A); where XI is the wanted array.
Upvotes: 1
Views: 97