code: function compareAscending(a, b) {
    var ai = a.idx,
        bi = b.idx;
  
    a = a.criteria;
    b = b.criteria;
  
    // ensure a stable sort in V8 and other engines
    // http://code.google.com/p/v8/issues/detail?id=90
    if (a !== b) {
      if (a > b || typeof a === 'undefined') {
        return 1;
      }
      /*istanbul ignore next*/
      if (a < b || typeof b === 'undefined') {
        return -1;
      }
    }
  
    /*istanbul ignore next*/
    return ai < bi ? -1 : 1;
  }
docs: Simplified stable sort implementation from Lo-Dash (http://lodash.com/)