title: How do I sort a JSON object by a nested value?
body: <p>I have an ajax call that returns a JSON object that is pretty complex and I'm having a hard time sorting it. </p>
  
  <p>My call:</p>
  
  <pre><code>$.post('/reports-ajax',arguments, function(data) {}
  </code></pre>
  
  <p>The response:</p>
  
  <pre><code>{
  "10001":{
      "unitname":"Fort Worth",
      "discounts":{"12-02-2012":"34.810000","12-03-2012":"20.810000","12-04-2012":"27.040000"},
      "gross":{"12-02-2012":"56.730000","12-03-2012":"19.350000","12-04-2012":"66.390000"},
      "net":{"12-02-2012":"61.920000","12-03-2012":"98.540000","12-04-2012":"39.350000"},
      "discounts_total":82.66,
      "gross_total":82.47,
      "net_total":99.81,
      "number":10001
      },
  "10002":{
      "unitname":"Dallast",
      "discounts":{"12-02-2012":"12.600000","12-03-2012":"25.780000","12-04-2012":"47.780000","12-05-2012":"45.210000"},
      "gross":{"12-02-2012":"29.370000","12-03-2012":"91.110000","12-04-2012":"60.890000","12-05-2012":"51.870000"},
      "net":{"12-02-2012":"16.770000","12-03-2012":"65.330000","12-04-2012":"13.110000","12-05-2012":"06.660000"},
      "discounts_total":131.37,
      "gross_total":33.24,
      "net_total":101.87,
      "number":10002
      },
  "32402":{
      "unitname":"Austin",
      "discounts":{"12-05-2012":"52.890000","12-02-2012":"22.430000","12-03-2012":"58.420000","12-04-2012":"53.130000"},
      "gross":{"12-05-2012":"25.020000","12-02-2012":"2836.010000","12-03-2012":"54.740000","12-04-2012":"45.330000"},
      "net":{"12-04-2012":"92.200000","12-05-2012":"72.130000","12-02-2012":"13.580000","12-03-2012":"96.320000"},
      "discounts_total":186.87,
      "gross_total":161.1,
      "net_total":174.23,
      "number":32402
      }
  }
  </code></pre>
  
  <p>I go over the function with a standard each call and do some awesome stuff with highcharts but now I'm trying to sort the responses by the net_total call and I can't figure it out. </p>
  
  <p>I tried <code>.sort()</code> and it errors out that its not a function. I've been reading for a while but guess I'm not finding the right results. This looked promising: <a href="https://stackoverflow.com/questions/979256/how-to-sort-an-array-of-javascript-objects">Sorting an array of JavaScript objects</a> but it failed with the <code>.sort</code> is not a function. It seems most <code>.sort</code> are on [] arrays not full objects.. </p>
  
  <p>Any help would be greatly appreciated. </p>