Sort an array based on an index array in C -
i trying sort many arrays in parallel. sort 1 array qsort , return int array specifies indices of original positions. int array, need sort other arrays.
array 1:
zzz yyy def abc cde xxx after sorting, index array , sorted array:idx position array
3 : abc 4 : cde 2 : def 5 : xxx 1 : yyy 0 : zzz now based on index array, need sort array
a b c d e f so becomes
d e c f b thanks lot
for (i=0; < 6; ++i) sortedarray[indexarray[i]] = anotherarray[i];
Comments
Post a Comment