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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -