title: How to sort an array of objects with multiple field values in JavaScript
body: <p>I found a great method to sort an array of objects based on one of the properties as defined at:</p>
  
  <p><a href="https://stackoverflow.com/questions/1129216/sorting-objects-in-an-array-by-a-field-value-in-javascript">Sort array of objects by string property value in JavaScript</a></p>
  
  <p>Using that function works perfectly for a single sort (on all browsers), and even a sort within another sort EXCEPT using Google Chrome!  Here is Ege Özcan's great sort routine for arrays of objects</p>
  
  <pre><code>function dynamicSort(property) { 
      return function (a,b) {
          return (a[property] &lt; b[property]) ? -1 : (a[property] &gt; b[property]) ? 1 : 0;
      }
  }
  </code></pre>
  
  <p>Using an array named "Data" (of course, my array has many more object pairs)...</p>
  
  <pre><code>var Data = [{Category: "Business", Value: "ABC"},{Category:"Personal", Value:"XYZ"}];
  </code></pre>
  
  <p>I can get a proper sort where the order is listed as all the values within each category by doing this...</p>
  
  <pre><code>Data.sort(dynamicSort("Value"));
  Data.sort(dynamicSort("Category"));
  </code></pre>
  
  <p>By first sorting on <code>Value</code>, and then by <code>Category</code>, my array puts all values in sorted order with all the Business-base values listed first and then all the Personal-based values.  Perfect!  Except in Chrome where the data is sorted properly by category, but the order of the values within each category seems rather random.</p>
  
  <p>Does any one know of a better way to do a sort within a sort that would also work in Chrome?</p>