title: Attempting to sort JSON by multiple fields with jQuery
body: <p>In reference to <a href="https://stackoverflow.com/questions/3230028/how-to-order-a-json-object-by-two-keys">this posting</a>; I can sort an Array of JSON Object by 2 fields.
  And this posting also states:</p>
  
  <blockquote>
    <p>"To add other columns to sort on, you can add other items in the array comparison."</p>
  </blockquote>
  
  <pre><code>//THIS WORKS BUT NEEDS TO SORT BY ALL 5 FIELDS..
  function sortRecords(a, b){
  //note the minus before -cmp, for descending order
  // field1 (Y or N), field2 (numeric), field3 (numeric), 
  // field4 (Y or N), field5 (Y or N)
  return cmp( 
      [-cmp(a.field1, b.field1), cmp(a.field2, b.field2)], 
      [-cmp(b.field1, a.field1), cmp(b.field2, a.field2)]
   );}
  
  //THIS ONLY SORTS BY field1 and field2
  function sortRecords(a, b){
  //note the minus before -cmp, for descending order
  // field1 (Y or N), field2 (numeric), field3 (numeric), 
  // field4 (Y or N), field5 (Y or N)
  return cmp( 
      [-cmp(a.field1, b.field1), cmp(a.field2, b.field2), cmp(a.field3, b.field3)], 
      [-cmp(b.field1, a.field1), cmp(b.field2, a.field2), cmp(b.field3, a.field3)]
   );}
  
  function cmp(x,y){
  return x &gt; y ? 1 : x &lt; y ? -1 : 0;
  }
  
  
  ///implementation
  data = $(data).sort(sortRecords);
  </code></pre>
  
  <blockquote>
    <p>What am I doing wrong here?</p>
  </blockquote>