title: Sort array containing objects based on another array
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4046967/javascript-sort-an-array-based-on-another-array-of-integers">JavaScript - Sort an array based on another array of integers</a><br>
    <a href="https://stackoverflow.com/questions/13304543/javascript-sort-array-based-on-another-array">Javascript - sort array based on another array</a>  </p>
  </blockquote>
  
  
  
  <p>If I have an array like this:</p>
  
  <pre><code>['one','four','two']
  </code></pre>
  
  <p>And another array like this:</p>
  
  <pre><code>[{
    key: 'one'
  },{
    key: 'two'
  },{
    key: 'four'
  }]
  </code></pre>
  
  <p>How would I sort the second array so it’s <code>key</code> property follows the order of the first? In this case, I want:</p>
  
  <pre><code>[{
    key: 'one'
  },{
    key: 'four'
  },{
    key: 'two'
  }]
  </code></pre>