Compare function for sorting PersitentObject instances by the list of criterias
@param $a First PersitentObject instance
@param $b First PersitentObject instance
@return -1, 0 or 1 whether a is less, equal or greater than b
in respect of the criteria
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;
  }
261487
public function similarity(&$A, &$B)
    {
        $alpha = $this->alpha;
        $beta = $this->beta;

        $a = array_fill_keys($A,1);
        $b = array_fill_keys($B,1);

        $min = min(count(array_diff_key($a,$b)),count(array_diff_key($b, $a)));
        $max = max(count(array_diff_key($a,$b)),count(array_diff_key($b, $a)));

        $intersect = count(array_intersect_key($a,$b));

        return $intersect/($intersect + ($beta * ($alpha * $min + $max*(1-$alpha)) ));
    }
482857
private function sortHeaders($a, $b)
    {
        $lowerA = strtolower($a);
        $lowerB = strtolower($b);
        $aPos = array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1;
        $bPos = array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1;

        if (-1 === $aPos && -1 === $bPos) {
            // just be sure to be determinist here
            return $a > $b ? -1 : 1;
        }

        if (-1 == $aPos) {
            return 1;
        } elseif (-1 == $bPos) {
            return -1;
        }

        return $aPos < $bPos ? -1 : 1;
    }
545769
public static function sort(ServiceDeliveryInterface $a, ServiceDeliveryInterface $b)
    {
        if ($a->getPriority() === $b->getPriority()) {
            return 0;
        }

        return $a->getPriority() > $b->getPriority() ? -1 : 1;
    }
898518
protected function sort($a, $b)
    {
        $complexityA = $a->complexity();
        $complexityB = $b->complexity();

        return $complexityB - $complexityA;
    }
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);
    }
93331
public function similarity(&$A, &$B)
    {
        // Make the arrays into sets
        $a = array_fill_keys($A,1);
        $b = array_fill_keys($B,1);

        // Count the cardinalities of the sets
        $a_count = count($a);
        $b_count = count($b);

        if ($a_count == 0 || $b_count == 0) {
            return 0;
        }

        // Compute the intersection and count its cardinality
        $intersect = count(array_intersect_key($a,$b));

        return $intersect/min($a_count,$b_count);
    }
1305839
private function sortLocalesByPriority(array $a, array $b)
    {
        $a = isset($a['priority']) ? $a['priority'] : 0;
        $b = isset($b['priority']) ? $b['priority'] : 0;

        if ($a === $b) {
            return 0;
        }
        return ($a < $b) ? (-1) : 1;
    }
1188471
public static function compare(Match $a, Match $b)
    {
        if ($a->quality !== $b->quality) {
            return $a->quality > $b->quality ? -1 : 1;
        }

        if ($a->index !== $b->index) {
            return $a->index > $b->index ? 1 : -1;
        }

        return 0;
    }
1373987
private function valuesAreEqual($a, $b)
    {
        if (is_array($a) && is_array($b)) {
            ksort($a);
            ksort($b);
        }

        return $a === $b;
    }
230082
protected static function uksortMatchFunc($a, $b)
	{
		$posa = array_search($a, self::$uksortMatchList);
		$posb = array_search($b, self::$uksortMatchList);
		if ($posa == $posb) {
			return 0;
		} else {
			return $posa > $posb ? 1 : -1;
		}
	}
1202898
protected function compare(string $a, string $b): int
    {
        global $sortOrder;

        $aIndex = array_search($a, $sortOrder);
        $bIndex = array_search($b, $sortOrder);
        if ($aIndex === false) {
            return -1;
        }

        if ($bIndex === false) {
            return 1;
        }

        return $aIndex - $bIndex;
    }
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 '=';
    }
1139594
public static function date_sort_callback($a, $b) {
		if($a->StartDate == $b->StartDate) {
			if($a->StartTime == $b->StartTime)
				return 0;
			else if(strtotime($a->StartTime) > strtotime($b->StartTime))
				return 1;
			else 
				return -1;
		}
		else if(strtotime($a->StartDate) > strtotime($b->StartDate))
			return 1;
		else 
			return -1;
		
	}
1125859
public static function compareList(array $a, array $b): int
    {
        foreach ($a as $i => $symbol) {
            // $b finished, but $a not yet
            if (!isset($b[$i])) {
                // $a > $b
                return 1;
            }
            // $a[$i] <=> $b[$i]
            $result = static::compare($symbol, $b[$i]);
            if ($result) {
                //# $a[$i] <> $b[$i]
                return $result;
            }
        }
        // $b starts with $a
        // if $b longer then $a
        if (count($b) > count($a)) {
            // $a < $b
            return -1;
        }
        // $a == $b
        return 0;
    }
1012255
private final function sortIntervals( $a, $b )
    {
        if( 0 !== $lowerCompare = $this->sort( $a[0], $b[0], self::NULL_IS_LOW ) ) {
            return $lowerCompare;
        }
        return -$this->sort( $a[1], $b[1], self::NULL_IS_HIGH );
    }
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;
        }
    }