code: function multiFieldSort(searchResults, fieldSpec) {
          // Move field names into an array, with primary field first
          var comparisons;
          if (Array.isArray(fieldSpec)) {
              comparisons = fieldSpec;
          } else {
              // TODO Deprecate this form of calling this function
              comparisons = [];
              _.forEach(fieldSpec, function (priority, key) {
                  comparisons[priority] = key;
              });
          }
  
          searchResults.sort(function (a, b) {
              var priority;
              for (priority = 0; priority < comparisons.length; priority++) {
                  var comparison = comparisons[priority];
                  if (typeof comparison === "function") {
                      var result = comparison(a, b);
                      if (result) {
                          return result;
                      }
                  } else {
                      var valueA = a[comparison];
                      var valueB = b[comparison];
                      if (typeof valueA === "string") {
                          valueA = valueA.toLowerCase();
                          valueB = valueB.toLowerCase();
                      }
  
                      if (valueA < valueB) {
                          return -1;
                      } else if (valueA > valueB) {
                          return 1;
                      }
                  }
                  // otherwise, move on to next sort priority
              }
              return 0; // all sort fields are equal
          });
      }
docs: Sorts an array of SearchResult objects on a primary field, followed by secondary fields
  in case of ties. 'fieldSpec' provides the priority order for fields, where the first entry is the primary field, for example:
  multiFieldSort(bugList, [ "milestone", "severity" ]);
  Would sort a bug list by milestone, and within each milestone sort bugs by severity.
  
  fieldSpec can also include comparator functions of the form normally used by the sort()
  function.
  
  Any fields that have a string value are compared case-insensitively. Fields used should be
  present on all SearchResult objects (no optional/undefined fields).
  
  @param {!Array.<SearchResult>} searchResults
  @param {!Array.<string, function>} fieldSpec