title: C - Sort two arrays the same way
body: <p>So I have two arrays (pointers actually), lets call them <code>a</code> and <code>b</code>. I want to first sort <code>a</code>, then save the exact swaps I did to get that sorted array and apply them to my vector <code>b</code>. Here's a short example of what I mean:</p>
  
  <pre><code>int *a, *b;
  //appropriate mallocs
  a[0] = 2; a[1] = 3; a[2] = 1;
  b[0] = 4; b[1] = 2; b[2] = 3;
  //sort a in decreasing order --&gt; a==[3, 2, 1]
  //sort b based on sorting of a --&gt; b==[2, 4, 3]
  </code></pre>
  
  <p>How I could achieve this without writing my own sort function?</p>