Compare by search weights.

Or fallback to dates or title

@param \Bolt\Legacy\Content $a
@param \Bolt\Legacy\Content $b

@return int
187555
private function compareSearchWeights(Content $a, Content $b)
    {
        if ($a->getSearchResultWeight() > $b->getSearchResultWeight()) {
            return -1;
        }
        if ($a->getSearchResultWeight() < $b->getSearchResultWeight()) {
            return 1;
        }
        if ($a['datepublish'] > $b['datepublish']) {
            // later is more important
            return -1;
        }
        if ($a['datepublish'] < $b['datepublish']) {
            // earlier is less important
            return 1;
        }

        return strcasecmp($a['title'], $b['title']);
    }
466928
public static function compare(string $a, string $b): string
    {
        return static::makeBin($a, 16) === static::makeBin($b, 16);
    }
540777
public function compare(NumericTypeInterface $a, NumericTypeInterface $b)
    {
        return $this->compEngine->compare($a, $b);
    }
142375
public static function compareVersions($a, $b)
    {
        $versionPos = max(count($a), count($b));
        while (count($a) < $versionPos) {
            $a[] = 0;
        }
        while (count($b) < $versionPos) {
            $b[] = 0;
        }

        for ($v = 0; $v < count($a); $v++) {
            if ((int)$a[$v] < (int)$b[$v]) {
                return '<';
            }
            if ((int)$a[$v] > (int)$b[$v]) {
                return '>';
            }
        }
        return '=';
    }
76456
public static function compareDateIntervals(DateInterval $a, DateInterval $b)
    {
        $current = Carbon::now();
        $passed = $current->copy()->add($b);
        $current->add($a);

        if ($current < $passed) {
            return -1;
        } elseif ($current > $passed) {
            return 1;
        }

        return 0;
    }
1317941
protected function sortRulesByOrder(AbstractRule $a, AbstractRule $b) {
        if ($a->getOrder() === $b->getOrder()) {
            return 0;
        }

        return $a->getOrder() < $b->getOrder()
            ? -1
            : 1;
    }
62778
public function sortAlerts($a, $b)
    {
        if ($a->{'type'} === $b->{'type'}) {
            return 0;
        }

        if (
            ($a->{'type'} === Alert::ERROR && $a->{'type'} !== $b->{'type'})
            || ($a->{'type'} === Alert::SUCCESS && $b->{'type'} === Alert::NOTICE)
        ) {
            return -1;
        }

        return 1;
    }
349467
public function Compare($a, $b)
    {
        $this->preOpMethodParamsCheck(array($a, $b));

        return $this->math->comp($a, $b);
    }
391011
protected static function fieldCompare(Document $a, Document $b) {
        $field = self::$orderByField;
        if (property_exists('\CloudControl\Cms\storage\entities\Document', $field)) {
            return strcasecmp($a->{$field}, $b->{$field});
        }

        if (!isset($a->fields->{$field}[0])) {
            return -3;
        }

        if (!isset($b->fields->{$field}[0])) {
            return 3;
        }

        return strcasecmp($a->fields->{$field}[0], $b->fields->{$field}[0]);
    }
418895
protected static function sortByOrder($a, $b) {
        if(!isset($a['link_order']) && isset($b['link_order'])){$a['link_order'] = ($b['link_order'] + 1);}
        if(!isset($b['link_order']) && isset($a['link_order'])){$b['link_order'] = ($a['link_order'] + 1);}
        if(isset($a['link_order']) && isset($b['link_order']) && is_numeric($a['link_order']) && is_numeric($b['link_order'])){
            return intval($a['link_order']) - intval($b['link_order']);
        }
        return 0;
    }
289618
protected function comparePluginPriorities($a, $b)
    {
        if ($this->pluginStorage[$a]['priority'] === $this->pluginStorage[$b]['priority']) {
            return 0;
        }

        return ($this->pluginStorage[$a]['priority'] > $this->pluginStorage[$b]['priority']) ? -1 : 1;
    }
691444
protected function sortByScore($a, $b)
    {

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

        return ($a->score > $b->score) ? -1 : 1;

    }
307706
public static function compare($a, $b) {
  if (self::makeBin($a, 16)==self::makeBin($b, 16))
   return TRUE;
  else
   return FALSE;
 }
997486
protected function compare($a, $b)
    {
        switch ($this->operator) {
            case '=':
            case '==': return $a == $b;
            case '!=': return $a != $b;
            case '<':  return $a < $b;
            case '>':  return $a > $b;
            case '<=': return $a <= $b;
            case '>=': return $a >= $b;
        }
    }
113780
public function sortItemsByPriority( eZPageBlockItem $a, eZPageBlockItem $b )
    {
        if ( $a->attribute('priority') > $b->attribute('priority') )
        {
            return -1;
        }
        else if ( $a->attribute('priority') < $b->attribute('priority') )
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
967467
private function compare(Item $itemA, Item $itemB): int
    {
        $itemAVolume = $itemA->getWidth() * $itemA->getLength() * $itemA->getDepth();
        $itemBVolume = $itemB->getWidth() * $itemB->getLength() * $itemB->getDepth();
        $volumeDecider = $itemAVolume <=> $itemBVolume;
        $weightDecider = $itemA->getWeight() - $itemB->getWeight();
        if ($volumeDecider !== 0) {
            return $volumeDecider;
        }
        if ($weightDecider !== 0) {
            return $weightDecider;
        }

        return $itemB->getDescription() <=> $itemA->getDescription();
    }
659692
protected function sortKeyLength($a, $b)
    {
        if (strlen($a) == strlen($b))
            return 0;
        if (strlen($a) > strlen($b))
            return -1;
        return 1;
    }