Hello everyone,
Since I am quite learner, I stuck in a small part in sorting values of a vector. I have two arrays like A=[13 14 5 9 3 2 1 5] another one B=[2 3 6]. Now , I should read the value in A corresponding indice B , which means= 2-->5,3--->9 and 6--->1 and sort the array B according to A values so I should obtain A=[6 2 3]. How can I do that ? Thank you in advance
write the comparison function for standard sort to use this alternative value.
so when sorting B, you use A[B[index1]] < A[B[index2]] instead of the usual B[index1] < B[index2]
if not using standard sort, you still do it that way, wherever you compare 2 things to swap them, use that idea.