Lets say, I have an Array, and I want to sort that Array's indexes, while iterating the array. Array would not be modified, but the indexes would be put in sorted order according to the value of the Array's elements. Let me give you an example.
Array = [ 1, 7, 5, 4, 3, 8 ]
The sorted indexes would be,
SortedIndexes = [ 0, 4, 3, 2, 1, 5 ]
I want it such that after I have iterated the whole array, I already have those sorted indexes. Now, what would be the best way to do this.
SortedIndexeswith the current iteration value per iteration.O(n log n)limit applies to comparison sorts. But I deleted that comment.counting sortorradix sortproducing the required indexes in sorted order (without iterating the array more than once)?