title: custom sort order on array of objects where the objects are different lengths and dynamic
body: <p>The objects are pulled from the backend, the objects can be different lengths and can contain different values.</p>
  <p>I want to custom sort these objects in this order of the array below:</p>
  <pre><code>let array = [&quot;packhouse&quot;, &quot;location&quot;, &quot;date&quot;, &quot;time&quot;]
  </code></pre>
  <p>this is what I can do (searching through the web):</p>
  <pre><code>var myArray = [{
      name: 'packhouse'
    },
    {
      name: 'notPackhouse',
      date: &quot;date&quot;
    },
    {
      name: 'a'
    },
  ];
  
  myArray.sort(function(a, b) {
    return array.indexOf(a.name) - sortOrder.indexOf(b.name);
  });
       
  </code></pre>
  <p>the data being pulled doesnt always have &quot;packhouse&quot; or could be a bigger length than the custom order array. is there a better solution for this?</p>