title: How to sort an array(in ascending order) based on the ranks of each element which is in the another array?
body: <p>Let two arrays</p>
  <pre><code>arr = [1,5,6,3,10] 
  
  
  rank = [100,0,1,100,2]
  </code></pre>
  <p>Based on the <code>rank</code> array (Which holds the <code>ranks</code> of the mirror elements in the <code>arr</code>) the result should be</p>
  <pre><code>[5,6,10,1,3]
  </code></pre>
  <p>The first element in the result is <code>5</code></p>
  <blockquote>
  <p>(The index of 5 in arr is <code>arr[1]</code> and the index of <code>0</code> in rank is
  <code>rank[1]</code>. This is how we have to take ranks.  0 is smallest of all ranks so 5 is printed first )</p>
  </blockquote>
  <p>The second element in the result is <code>6</code></p>
  <blockquote>
  <p>The index of <code>6</code> in <code>arr</code> array is at the index <code>arr[2]</code> and its rank is
  <code>1</code> because that is at the index <code>rank[2]</code>. 1 is the second smallest
  of all ranks so 6 is printed next)
  This is how we have to sort the array based on the rank array.</p>
  <pre><code>Here if two ranks are same then we have to compare the values in the array itself and print the smaller first
  arr[0] = 1 and arr[3] = 3 Both having same ranks 100. So compare those elements and print the smallest value. That gives the
  </code></pre>
  <p>result
  <code>5,6,10,1,3</code></p>
  </blockquote>