To be called with {@see uasort()}.

@param  SecondaryMenuGroupInterface $a Sortable entity A.
@param  SecondaryMenuGroupInterface $b Sortable entity B.
@return integer Sorting value: -1, 0, or 1
436879
protected function sortGroupsByPriority(
        SecondaryMenuGroupInterface $a,
        SecondaryMenuGroupInterface $b
    ) {
        $a = $a->priority();
        $b = $b->priority();

        if ($a === $b) {
            return 0;
        }
        return ($a < $b) ? (-1) : 1;
    }
184699
private function compareLevel(string $a, string $b): int {
        $i = array_search($a, static::$levels);
        if ($i === false) {
            throw new InvalidArgumentException("Log level is invalid: $a", 500);
        }

        return $i <=> array_search($b, static::$levels);
    }
1254002
public static function alphaDepthScoreSort(Section $a, Section $b)
    {
        $aNumeric = self::isReferenceNumeric($a->getReference());
        $bNumeric = self::isReferenceNumeric($b->getReference());

        if ($aNumeric && $bNumeric) {
            return self::depthScoreSort($a, $b);
        } elseif ($aNumeric) {
            return -1;
        } elseif ($bNumeric) {
            return 1;
        } else {
            return strnatcmp(
                $a->getReferenceDotDelimited(),
                $b->getReferenceDotDelimited()
            );
        }
    }
502830
public function compare(PersistentObject $a, PersistentObject $b) {
    // we compare for each criteria and sum the results for $a, $b
    // afterwards we compare the sums and return -1,0,1 appropriate
    $sumA = 0;
    $sumB = 0;
    $maxWeight = sizeOf($this->sortCriteria);
    $i = 0;
    foreach ($this->sortCriteria as $criteria => $sortType) {
      $weightedValue = ($maxWeight-$i)*($maxWeight-$i);
      $aGreaterB = 0;
      // sort by id
      if ($criteria == self::ATTRIB_OID) {
        if ($a->getOID() != $b->getOID()) {
          ($a->getOID() > $b->getOID()) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by type
      else if ($criteria == self::ATTRIB_TYPE) {
        if ($a->getType() != $b->getType()) {
          ($a->getType() > $b->getType()) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by value
      else if($a->getValue($criteria) != null || $b->getValue($criteria) != null) {
        $aValue = strToLower($a->getValue($criteria));
        $bValue = strToLower($b->getValue($criteria));
        if ($aValue != $bValue) {
          ($aValue > $bValue) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by property
      else if($a->getProperty($criteria) != null || $b->getProperty($criteria) != null) {
        $aProperty = strToLower($a->getProperty($criteria));
        $bProperty = strToLower($b->getProperty($criteria));
        if ($aProperty != $bProperty) {
          ($aProperty > $bProperty) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // calculate result of current criteria depending on current sorttype
      if ($sortType == self::SORTTYPE_ASC) {
        if ($aGreaterB == 1) { $sumA += $weightedValue; }
        else if ($aGreaterB == -1) { $sumB += $weightedValue; }
      }
      else if ($sortType == self::SORTTYPE_DESC) {
        if ($aGreaterB == 1) { $sumB += $weightedValue; }
        else if ($aGreaterB == -1) { $sumA += $weightedValue; }
      }
      else {
        throw new IllegalArgumentException("Unknown SORTTYPE.");
      }
      $i++;
    }
    if ($sumA == $sumB) { return 0; }
    return ($sumA > $sumB) ? 1 : -1;
  }
736487
protected function yearSort($a, $b)
    {
        $aDates = $this->extractNewestDates($a);
        $bDates = $this->extractNewestDates($b);

        if (count($aDates) > 0 && count($bDates) > 0) {
            return $bDates[0] - $aDates[0];
        } elseif (count($aDates) > 0 && count($bDates) === 0) {
            return -1;
        } elseif (count($aDates) === 0 && count($bDates) > 0) {
            return 1;
        } else {
            return 0;
        }
    }
1350349
public function sortNodes($a, $b)
    {
        if ($a->getSort() < $b->getSort()) {
            return -1;
        } elseif ($a->getSort() > $b->getSort()) {
            return 1;
        } elseif ($a->getLeft() < $b->getLeft()) {
            return -1;
        } elseif ($a->getLeft() > $b->getLeft()) {
            return 1;
        }

        return 0;
    }
924811
public static function sort_custom_menu_items(custom_menu_item $itema, custom_menu_item $itemb) {
        $itema = $itema->get_sort_order();
        $itemb = $itemb->get_sort_order();
        if ($itema == $itemb) {
            return 0;
        }
        return ($itema > $itemb) ? +1 : -1;
    }
728200
private function sortTabs(OrderedTabInterface $tab1, OrderedTabInterface $tab2): int
    {
        return $tab1->getOrder() <=> $tab2->getOrder();
    }
947426
public function sortReports($a, $b)
    {
        return $this->reportsProvider->compareCategories($a['category'], $a['subcategory'], $a['order'], $b['category'], $b['subcategory'], $b['order']);
    }
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;
    }
387739
public function queueForDuplicationSort($a, $b)
    {
        if ($a['level'] > $b['level']) {
            return 1;
        }
        if ($a['level'] < $b['level']) {
            return -1;
        }
        if ($a['cDisplayOrder'] > $b['cDisplayOrder']) {
            return 1;
        }
        if ($a['cDisplayOrder'] < $b['cDisplayOrder']) {
            return -1;
        }
        if ($a['cID'] > $b['cID']) {
            return 1;
        }
        if ($a['cID'] < $b['cID']) {
            return -1;
        }

        return 0;
    }
486331
protected static function sortGroupList(Node $a, Node $b)
  {
    if(get_class($a) != get_class($b))
    {
      return 0;

      /* workaround for PHP bug #50688 */
      throw new Exception("invalid parameter", 0x602);
    }

    if(!$a instanceof Servergroup && !$a instanceof Channelgroup)
    {
      return 0;

      /* workaround for PHP bug #50688 */
      throw new Exception("convert error", 0x604);
    }

    if($a->getProperty("sortid", 0) != $b->getProperty("sortid", 0) && $a->getProperty("sortid", 0) != 0 && $b->getProperty("sortid", 0) != 0)
    {
      return ($a->getProperty("sortid", 0) < $b->getProperty("sortid", 0)) ? -1 : 1;
    }

    return ($a->getId() < $b->getId()) ? -1 : 1;
  }
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);
    }
1226106
private static function sortReports ($a, $b){
    	$a = json_decode($a, true);
    	$b = json_decode($b, true);
    	
    	if ($a['value']['optional'] == $b['value']['optional']){
    		return 0;
    	}
    	else{
    		return ($a['value']['optional'] < $b['value']['optional']) ? -1 : 1;
    	}
    }
784660
protected function sortByScore(Identification $a, Identification $b)
    {
        if (is_null($this->scoreKey)) {
            throw new \BadMethodCallException('The key to sort on must be defined using SetScoreKey() prior to sorting.');
        }
        
        if ($a->getScore($this->scoreKey) == $b->getScore($this->scoreKey)) {
            return 0;
        }
        
        return $a->getScore($this->scoreKey) > $b->getScore($this->scoreKey) ? $this->returnTrue : $this->returnFalse;
    }
320586
protected static function _sortObjects(&$a, &$b)
  {
    $key = self::$sortKey;

    for($i=0, $count=count($key); $i<$count; $i++){
      if ( isset(self::$sortDirection[$i]) ){
        $direction = self::$sortDirection[$i];
      }

      if ( isset(self::$sortCase[$i]) ){
        $caseSensitive = self::$sortCase[$i];
      }

      if ( isset(self::$sortLocale[$i]) ){
        $locale = self::$sortLocale[$i];
      }

      $va = $a->$key[$i];
      $vb = $b->$key[$i];

      if ( (is_bool($va) or is_numeric($va)) and (is_bool($vb) or is_numeric($vb)) ){
        $cmp = $va - $vb;
      }
      elseif ( $caseSensitive ){ 
        $cmp = strcmp($va, $vb, $locale);
      }
      else {
        $cmp = strcasecmp($va, $vb, $locale);
      }

      if ( $cmp > 0 ){

        return $direction;
      }

      if ( $cmp < 0 ){
        return -$direction;
      }
    }

    return 0;
  }
1241400
private function tupleSort(array $a, array $b)
    {
        $max = max(count($a), count($b));
        for ($i = 0; $i < $max; ++$i) {
            if ($a[$i] < $b[$i]) {
                return -1;
            } else {
                if ($a[$i] > $b[$i]) {
                    return 1;
                }
            }
        }

        if (count($a) == count($b)) {
            return 0;
        } else {
            if (count($a) < count($b)) {
                return -1;
            } else {
                return 1;
            }
        }
    }