title: Sort a vector and store the index of entry of the sorted vector in the original vector
body: <p>In matlab, I have a vector </p>
  
  <pre><code> A = [2,3,4,1];
  </code></pre>
  
  <p>I want to sort it in ascending order, which becomes</p>
  
  <pre><code> [B,index] = sort(A);
   B = 1,2,3,4 
   index = 4 1 2 3;
  </code></pre>
  
  <p>I have another vector </p>
  
  <pre><code> C = [10,20,30,40]
  </code></pre>
  
  <p>I want to use index to let C becomes </p>
  
  <pre><code> [20 30 40 10]
  </code></pre>
  
  <p>However, if I just do</p>
  
  <pre><code> C(index)
  </code></pre>
  
  <p>It becomes</p>
  
  <pre><code> 40,10,20,30
  </code></pre>
  
  <p>This is not what I want. I wonder is there a way of using index and sort to achieve my goal?</p>