Hi all,
i have been trying to write a program that sorts an array for its
values in increasing order but generates the o/p as the sorted indices
of those respective values.
To make my question clear here is an ex. :
A[6]={2,6,4,6,2,2}; // array as i/p
B[6]={2,2,2,4,6,6}; //sorted array
Now the expected o/p is the indices - A[o],A[4],A[5],A[2],A[1],A[3] !!
Problem is after sorting the array (which uses swapping) the initial
indices are lost!
To avoid this i created a new array(similar to A[] & compared it
element-wise with sorted array to find a match & then look out for the
index with a match.But the place where i get stuck is discarding the
initially found matches!!
I hope my problem here is clear.
Kindly suggest me some way to find the solution.
Also let me know if this approach is OK or if there exists a simpler
way to reach the required solution.
Your suggestions/comments would be of great help to me.
Best regards,
anand.