title: Sorting an array without losing the original index in C
body: <p>I'm working on a function that gets an array and sort it without losing the original indexes, for example: </p>
  
  <pre><code>    originalArray[5] = {9, 2, 3, 4, 15};
      // code
      // ..
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>sortedArr[5] = {2, 3, 4, 9, 15};
  index[5] = {1, 2, 3, 0, 4};
  </code></pre>
  
  <p>notice how </p>
  
  <pre><code>/*
  index[0] == 1 because sortedArr[0] == originalArr[1]
  index[3] == 0 because sortedArr[3] == originalArr[0]
  index[4] == 4 because sortedArr[4] == originalArr[4]
  */
  </code></pre>
  
  <p>and so on the point is saving the indexes of the numbers so I can use them in another function. in the example I made two array (sorted and original) it should be the same array I made those just to explain my point. the Time complexity should is limited to O(n*log(n)). n represents the size of the array, (the maximum is 100).</p>
  
  <p>its recommended (the teacher recommended it for us) to use a function of the signature </p>
  
  <pre><code>void rem_sort(int array[], int index[], int size)
  </code></pre>
  
  <p>.
  EDIT: so everyone have been asking me what have I tried so far, if that helps you to assist me, I'm sorry I didn't mention it first, anyway this is what I tried so far, first I tried to sort the array I succeeded but I lost the indexes of the original array and that's not my point, so I thought if I make a new "temp" array and copy my original array to it and sort it this way I wont affect my original array but I cant get the indexes right (with this complexity), I thought about using pointers but I don't know how should I do it so I'm stuck! </p>
  
  <p>I appreciate your help!</p>