title: Sort array using values from separate hash
body: <p>I have an array of IDs and a separate hash that dictates how those IDs should be ordered.  Something like this:</p>
  
  <p>Array:</p>
  
  <pre><code>[
    7,
    3,
    2,
  ]
  </code></pre>
  
  <p>Sort ranks:</p>
  
  <pre><code>{
    1 =&gt; 50,
    2 =&gt; 70,
    3 =&gt; 10,
    4 =&gt; 80,
    5 =&gt; 60,
    6 =&gt; 20,
    7 =&gt; 0,
  }
  </code></pre>
  
  <p>I want to elegantly reverse sort the first array by using the values of the hash.  So the result should be this:</p>
  
  <pre><code>[
      2,
      3,
      7,
  ]
  </code></pre>
  
  <p>I know there are brute force methods, but is there an easier and more performant way to do this?</p>