title: jQuery/JS: Sorting array based upon another array?
body: <p>I want to sort a JSON object/array (shown below as <code>myArray</code>), upon values from another array - very close to the MYSQL query <code>MYSQL WHERE IN(1,2,3)</code>. I was able to get a <a href="https://stackoverflow.com/questions/4423526/javascript-filtering-twodimensional-array">great answer by Nick Craver</a> on how to sort by one property and value, but how can I do this with multiple values from my other array?</p>
  
  <p><strong>Here's my dataset Json array:</strong></p>
  
  <pre><code>var myArray = [
  {
      "id":"2",
      "name":"My name",
      "properties":{"prop1":"value1"}
  }];
  </code></pre>
  
  <p><strong>And the array which I want to sort upon (serialized, coming straight from a form):</strong></p>
  
  <pre><code>var sortArray = [ { "prop1":"value1","prop2":"value2" }];
  </code></pre>
  
  <p><strong>The current sorting function as it looks right now (courtesy Nick Craver):</strong></p>
  
  <pre><code>function filterDataset(property, value){
      var newArray = [];
  
      for (var i = 0, l = myArray.length; i &lt; l; i++) {
          if (myArray[i].properties[property] === value) 
          newArray.push(myArray[i]);
      }            
      return newArray;
  }
  </code></pre>