title: Filter and sort array of objects
body: <p>I have an array of objects</p>
  
  <pre><code>const a = [
    { name: 'z', items: [..] },
    { name: 'x', items: [..] },
    { name: 'y', items: [..] },
    { name: 'a', items: [..] },
  ]
  </code></pre>
  
  <p>I would like to select and reorder such that I transform the array into</p>
  
  <pre><code>const a_new = [
    { name: 'x', items: [..] },
    { name: 'y', items: [..] },
    { name: 'z', items: [..] },
  ]
  </code></pre>
  
  <p>i.e. I only want those with name <code>x</code>, <code>y</code>, and <code>z</code> and I want it ordered by some specific order (not just alphanumerically).</p>
  
  <p>So I would like to, for instance, specify an array <code>['x', 'y', 'z']</code>, indicating which names I would allow and how they should be sorted.</p>
  
  <p>Could it be something like</p>
  
  <pre><code>['x', 'y', 'z'].map(allowedValue =&gt; a.find(b =&gt; b.name === allowedValue))
  </code></pre>
  
  <p>It just seems a bit memory heavy?</p>