title: C++ swap/sort algorithm
body: <p>Given the following:</p>
  
  <pre><code>Container A; //contains n data entries
  vector&lt;int&gt; B; //indexes of A that need to be swapped
  vector&lt;int&gt; C; // Where the entry needs to be moved to, a randomly sorted version of B
  //B.size() &lt;= A.size() - not all may be swapped
  //C.size() = B.size()
  
  swap(container &amp;X, int i, int j); //moves X[i]-&gt;X[j] and X[j]-&gt;X[i]
  </code></pre>
  
  <p>Here is what I need to do:</p>
  
  <p>For the data in container A, I need to move each index specified in B to the corresponding index in C using a swap function. I cannot create another Container in the process. There is also the chance that an index marked to be sorted may not move (B[i] = C[i]).</p>
  
  <p>For example:</p>
  
  <pre><code>A=[a, b, c, d, e, f, g, h, i, j];
  B=[0, 1, 3, 6, 9]; //move these entries to....
  C= [3, 6, 9, 0, 1]; //these entries
  </code></pre>
  
  <p>After running the algorithm A would look like this:</p>
  
  <pre><code>A=[g, j, c, a, e, f, b, h, i, d]
  </code></pre>
  
  <p>Does anyone have a good solution to this? I've been raking my brain the past few days over this. </p>