If we have array of element, what is the efficient way to calculate index of each element after sorting that array? is there any way to efficiently reuse sort
function in c++
or java
?
for example:
double[] array=[".2",".6",".3",".5",".1"];
I want something like this:
ans= [ 1, 4, 2, 3, 0 ];
that's because after sort .2
place in index 1
, .6
place in index 4
, .3
place in index 2
and so on.