code: function xpathSortByKey(v1, v2) {
    // NOTE: Sort key vectors of different length never occur in
    // xsltSort.
  
    for (var i = 0; i < v1.key.length; ++i) {
      var o = v1.key[i].order == 'descending' ? -1 : 1;
      if (v1.key[i].value > v2.key[i].value) {
        return +1 * o;
      } else if (v1.key[i].value < v2.key[i].value) {
        return -1 * o;
      }
    }
  
    return 0;
  }
docs: Sorts by all order criteria defined. According to the JavaScript spec ([ECMA] Section 11.8.5), the compare operators compare strings as strings and numbers as numbers.  NOTE: In browsers which do not follow the spec, this breaks only in the case that numbers should be sorted as strings, which is very uncommon.