title: Sorting a JSON object by two fields
body: <p>I have the follow json object</p>
  
  <pre><code>[
  {"PARTNERNAME":"Partner 1","DISTANCE":20,"TYPE":"1"},
  {"PARTNERNAME":"Partner 2","DISTANCE":14,"TYPE":"2"},
  {"PARTNERNAME":"Partner 3","DISTANCE":60,"TYPE":"2"},
  {"PARTNERNAME":"Partner 4","DISTANCE":37,"TYPE":"1"},
  {"PARTNERNAME":"Partner 5","DISTANCE":25,"TYPE":"2"},
  {"PARTNERNAME":"Partner 6","DISTANCE":90,"TYPE":"1"},
  {"PARTNERNAME":"Partner 7","DISTANCE":49,"TYPE":"1"}
  ]
  </code></pre>
  
  <p>I'd like to sort it first by type and then by distance so the result would be the following.</p>
  
  <pre><code>[
  {"PARTNERNAME":"Partner 1","DISTANCE":20,"TYPE":"1"},
  {"PARTNERNAME":"Partner 4","DISTANCE":37,"TYPE":"1"},
  {"PARTNERNAME":"Partner 7","DISTANCE":49,"TYPE":"1"},
  {"PARTNERNAME":"Partner 6","DISTANCE":90,"TYPE":"1"},
  {"PARTNERNAME":"Partner 2","DISTANCE":14,"TYPE":"2"},
  {"PARTNERNAME":"Partner 5","DISTANCE":25,"TYPE":"2"},
  {"PARTNERNAME":"Partner 3","DISTANCE":60,"TYPE":"2"}
  ]
  </code></pre>
  
  <p>I have the following code that sorts it by one field but I can get it to sort by two fields. Is this possible?</p>
  
  <pre><code>var sortedData = propertyArray.sort(sortByProperty('DISTANCE'));
  function sortByProperty(property) {
              'use strict';
              return function (a, b) {
                  var sortStatus = 0;
                  if (a[property] &lt; b[property]) {
                      sortStatus = -1;
                  } else if (a[property] &gt; b[property]) {
                      sortStatus = 1;
                  }
  
                  return sortStatus;
              };
          }
  </code></pre>