title: Sort a list of strings given a predefined order
body: <p>I have an array of colors that I'd like to sort into order. However, I don't want to sort them using their "natural" ordering, but rather to keep them in this order:</p>
  
  <pre><code>var order = ['white', 'yellow', 'violet', 'blue', 'orange', 'red', 'maroon', 'brown', 'black'];
  </code></pre>
  
  <p>So, for example, sorting this array</p>
  
  <pre><code>var items = ['blue', 'violet', 'white', 'black', 'orange'];
  </code></pre>
  
  <p>should give back</p>
  
  <pre><code>['white', 'violet', 'blue', 'orange', 'black'];
  </code></pre>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>var itemsInOrder = [];
  
  for (var i=0; i&lt;order.length; i++) {
      if (items.indexOf(order[i]) &gt; -1) {
          itemsInOrder.push(order[i]);
      }
  }
  </code></pre>
  
  <p>I'm not sure how well it scales - what if <code>order</code> has 100 or 1000 elements but 'items' has 10?</p>
  
  <p>What is a good, scalable way to accomplish this?</p>