Sort the parsed accept-language header array

@author   Jelle De Loecker       <jelle@develry.be>
@since    0.0.1
@version  0.0.1

@param    {Object}   a
@param    {Object}   b
772555
function qualityCmp(a, b) {
	if (a.quality === b.quality) {
		return 0;
	} else if (a.quality < b.quality) {
		return 1;
	} else {
		return -1;
	}
}
61447
function(arr) {
  arr = arr.sort((a, b) => {
    if (a.index > b.index) {
      return 1;
    }
    if (a.index === b.index) {
      return 0;
    }
    return -1;
  });
  //return ts objects
  return arr.map((o) => o.ts);
}
559617
function sortFiles (a, b) {
  if (a.type === b.type) {
    if (a.file === b.file) {
      var ai = a.start || a.mtime || a.index
      var bi = b.start || b.mtime || b.index
      if (sort === 'desc') {
        return parseFloat(bi) - parseFloat(ai)
      } else {
        return parseFloat(ai) - parseFloat(bi)
      }
    } else {
      var ai = a.mtime || a.index
      var bi = b.mtime || b.index
      if (sort === 'desc') {
        return parseFloat(bi) - parseFloat(ai)
      } else {
        return parseFloat(ai) - parseFloat(bi)
      }
    }
  } else {
    var order = [1, 2, 0]
    return order[b.type] - order[a.type]
  }
}
915309
function(a, b)
{
   var rval = 0;
   
   /*
   3. For each property, compare sorted object values.
   3.1. The bnode with fewer objects is first.
   3.2. For each object value, compare only literals and non-bnodes.
   3.2.1. The bnode with fewer non-bnodes is first.
   3.2.2. The bnode with a string object is first.
   3.2.3. The bnode with the alphabetically-first string is first.
   3.2.4. The bnode with a @literal is first.
   3.2.5. The bnode with the alphabetically-first @literal is first.
   3.2.6. The bnode with the alphabetically-first @type is first.
   3.2.7. The bnode with a @language is first.
   3.2.8. The bnode with the alphabetically-first @language is first.
   3.2.9. The bnode with the alphabetically-first @id is first.
   */
   
   for(var p in a)
   {
      // skip IDs (IRIs)
      if(p !== '@id')
      {
         // step #3.1
         var lenA = (a[p].constructor === Array) ? a[p].length : 1;
         var lenB = (b[p].constructor === Array) ? b[p].length : 1;
         rval = _compare(lenA, lenB);

         // step #3.2.1
         if(rval === 0)
         {
            // normalize objects to an array
            var objsA = a[p];
            var objsB = b[p];
            if(objsA.constructor !== Array)
            {
               objsA = [objsA];
               objsB = [objsB];
            }
            
            // compare non-bnodes (remove bnodes from comparison)
            objsA = objsA.filter(function(e) {return !_isNamedBlankNode(e);});
            objsB = objsB.filter(function(e) {return !_isNamedBlankNode(e);});
            rval = _compare(objsA.length, objsB.length);
         }
         
         // steps #3.2.2-3.2.9
         if(rval === 0)
         {
            objsA.sort(_compareObjects);
            objsB.sort(_compareObjects);
            for(var i = 0; i < objsA.length && rval === 0; ++i)
            {
               rval = _compareObjects(objsA[i], objsB[i]);
            }
         }
         
         if(rval !== 0)
         {
            break;
         }
      }
   }
   
   return rval;
}
148109
function sort(comparefn) {
	    return comparefn === undefined ? $sort.call(_toObject(this)) : $sort.call(_toObject(this), _aFunction(comparefn));
	  }
203393
function byPriority(a, b) {
      var diff = b.priority - a.priority;
      if (diff !== 0) return diff;
      if (a.name !== b.name) return (a.name < b.name) ? -1 : 1;
      return a.index - b.index;
    }
405142
function compareCategories(a, b) {
  return a === b                 ?   0
  :      a === '(Uncategorised)' ?   1
  :      b === '(Uncategorised)' ?  -1
  :      /* otherwise */            compare(a, b);
}
1240876
function sortByLinePoint(a, b) {
  let lineA = a.lines[0];
  let lineB = b.lines[0];
  return sortByPoint(
    {x: lineA[0], y: lineA[1]},
    {x: lineB[0], y: lineB[1]}
  );
}
257696
private function sort(array $acceptLanguages)
    {
        $topAcceptLanguages = [];
        $sortedAcceptLanguages = [];

        foreach ($acceptLanguages as $acceptLanguage) {
            if ($acceptLanguage->getQuality() === 1.0) {
                $topAcceptLanguages[] = $acceptLanguage;
            } else {
                $sortedAcceptLanguages[] = $acceptLanguage;
            }
        }

        usort($sortedAcceptLanguages, function (AcceptLanguage $a, AcceptLanguage $b) {
            return $a->getQuality() > $b->getQuality() ? -1 : 1;
        });

        return array_merge($topAcceptLanguages, $sortedAcceptLanguages);
    }
335461
private function sortBySelectorPrecedence(array $a, array $b)
    {
        $precedenceA = $this->getCssSelectorPrecedence($a['selector']);
        $precedenceB = $this->getCssSelectorPrecedence($b['selector']);

        // We want these sorted in ascending order so selectors with lesser precedence get processed first and
        // selectors with greater precedence get sorted last.
        $precedenceForEquals = ($a['line'] < $b['line'] ? -1 : 1);
        $precedenceForNotEquals = ($precedenceA < $precedenceB ? -1 : 1);
        return ($precedenceA === $precedenceB) ? $precedenceForEquals : $precedenceForNotEquals;
    }
983240
private function sortChildren(NodeObject $a, NodeObject $b)
    {
        if ($a->getType() == $b->getType()) {
            $names = [$a->getName(), $b->getName()];
            sort($names);

            return ($a->getName() === $names[0]) ? -1 : 1;
        }

        return $a->getType() == NodeObject::TYPE_TREE || $b->getType() == NodeObject::TYPE_BLOB ? -1 : 1;
    }
295255
function sortCompare(a,b,sortProperty) {
    var aVal = DotNotationPointers(a, sortProperty)[0].val // todo: figure out what mongo does with multiple matching sort properties
    var bVal = DotNotationPointers(b, sortProperty)[0].val

    if(aVal > bVal) {
        return 1
    } else if(aVal < bVal) {
        return -1
    } else {
        return 0
    }
}
1031201
function defSortFn (a, b) {
    const a1 = `${a}`;
    const b1 = `${b}`;
    if (a1 < b1) {
        return -1;
    }
    if (a1 > b1) {
        return 1;
    }
    return 0;
}
149541
protected function sortCompareValues($a, $b)
    {
        if (is_numeric($a) && is_numeric($b)) {
            return $this->sortCompareNumeric((float)$a, (float)$b);
        }

        if (is_string($a) && is_string($b)) {
            return $this->sortCompareStrings($a, $b);
        }

        return ($a < $b) ? -1 : (int)($a > $b);
    }
981873
function sortFeatures({ stage: a, id: aa }, { stage: b, id: bb }) {
	return b - a || (aa < bb ? -1 : aa > bb ? 1 : 0);
}
883740
private function sortByPriority($a, $b)
    {
        $a = $a['_priority'];
        $b = $b['_priority'];

        if ($a == $b) {
            return 0;
        }

        return ($a < $b) ? -1 : 1;
    }
774759
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;
}