title: Quick sort an array and store the new ordering in C
body: <p>I have two int arrays *start and *end whose size might be 5 millions. *start stores the start node number of an edge and *end stores the end node number. Now I want to sort *start in ascending way and stores the new ordering scheme, like before sorting:</p>
  
  <pre><code>start[0] = 5
  start[1] = 7
  start[2] = 8
  start[3] = 1
  start[4] = 4
  </code></pre>
  
  <p>after sorting, it becomes</p>
  
  <pre><code>start[0] = 1
  start[1] = 4
  start[2] = 5
  start[3] = 7
  start[4] = 8
  </code></pre>
  
  <p>I also want to stores the new ordering scheme which is "3 4 0 1 2". The reason I want to store this new ordering scheme is that I need to use it the rearrange *end. There is a function qsort() in C library but it can only do the sorting job but doesn't store the ordering scheme. Is there any other functions which can do both? Or how to write an function on my own? Thanks a lot.</p>