I am trying to write a function that takes array like this [4,7,2,1,9] then return another array like this
[4,1,0,2,3]// the sorted indices descending for the input array values
I've tried this code but it isn't working properly, I want to hepl me for writing a function that sort array like this with minimum cost
public void solution(int[] D)
{
int[] sorted = new int[D.Length];
for (int i = 0; i < D.Length; i++)
{
int ind = 0;
for (int j = 0; j < D.Length; j++)
{
if (D[j] > D[i] ) //&&
{
ind = j;
}
}
sorted[i] = ind;
}
}