ページ情報の配列を並び替える。

@param string $a 比較対象1のページID
@param string $b 比較対象2のページID
@return int 並び順の前後関係 (`1`|`0`|`-1`)
351494
private function usort_sitemap( $a , $b ){
		$page_info_a = $this->get_page_info( $a );
		$page_info_b = $this->get_page_info( $b );
		$orderby_a = $page_info_a['orderby'];
		$orderby_b = $page_info_b['orderby'];
		if( strlen( $orderby_a ) && !strlen( $orderby_b ) ){
			return	-1;
		}elseif( strlen( $orderby_b ) && !strlen( $orderby_a ) ){
			return	1;
		}elseif( $orderby_a < $orderby_b ){
			return	-1;
		}elseif( $orderby_a > $orderby_b ){
			return	1;
		}
		return	0;
	}
557603
private function compare(int $a, int $b)
    {
        $x = $this->heap[$a];
        $y = $this->heap[$b];

        // Compare priority, using insertion stamp as fallback.
        return ($x->priority <=> $y->priority) ?: ($y->stamp <=> $x->stamp);
    }
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;
    }
1034855
public function calcdiffer($a, $b)
 {
  $alen = strlen($a);
  $blen = strlen($b);
  $aptr = 0;
  $bptr = 0;

  $ops = array();

  while($aptr < $alen && $bptr < $blen)
  {
    $matchlen = $this->matchlen(substr($a, $aptr), substr($b, $bptr));
    if($matchlen)
    {
      $str = substr($a, $aptr, $matchlen);
      $ops[] = array(self::EQUAL, $str, strlen($str) );
      $aptr += $matchlen;
      $bptr += $matchlen;
      continue;
    }
    /* Difference found */

    $bestlen=0;
    $bestpos=array(0,0);
    for($atmp = $aptr; $atmp < $alen; $atmp++)
    {
      for($btmp = $bptr; $btmp < $blen; $btmp++)
      {
        $matchlen = $this->matchlen(substr($a, $atmp), substr($b, $btmp));
        if($matchlen>$bestlen)
        {
          $bestlen=$matchlen;
          $bestpos=array($atmp,$btmp);
        }
        if($matchlen >= $blen-$btmp)break;
      }
    }
    if(!$bestlen)break;

    $adifflen = $bestpos[0] - $aptr;
    $bdifflen = $bestpos[1] - $bptr;

    if($adifflen)
    {
      $str = substr($a, $aptr, $adifflen);
      $ops[] = array(self::DEL, $str, strlen($str) );
      $aptr += $adifflen;
    }
    if($bdifflen)
    {
      $str = substr($b, $bptr, $bdifflen);
      $ops[] = array(self::ADD, $str, strlen($str) );
      $bptr += $bdifflen;
    }
    $str = substr($a, $aptr, $bestlen);
    $ops[] = array(self::EQUAL, $str, strlen($str) );
    $aptr += $bestlen;
    $bptr += $bestlen;
  }
  if($aptr < $alen)
  {
    /* b has too much stuff */
    $str = substr($a, $aptr);
    $ops[] = array(self::DEL, $str, strlen($str) );
  }
  if($bptr < $blen)
  {
    /* a has too little stuff */
    $str = substr($b, $bptr);
    $ops[] = array(self::ADD, $str, strlen($str)  );
  }
  return $ops;
 }
893651
public function compare($a, $b)
    {
        if ($this->collator instanceof \Collator) {
            return $this->collator->compare($a, $b);
        } else {
            return $a == $b ? 0 : ($a > $b ? 1 : -1);
        }
    }
35212
private function positiveCompare(DecimalNumber $a, DecimalNumber $b)
    {
        // compare integer length
        $intLengthCompare = $this->compareNumeric(
            strlen($a->getIntegerPart()),
            strlen($b->getIntegerPart())
        );
        if ($intLengthCompare !== 0) {
            return $intLengthCompare;
        }

        // integer parts are equal in length, compare integer part
        $intPartCompare = $this->compareBinary($a->getIntegerPart(), $b->getIntegerPart());
        if ($intPartCompare !== 0) {
            return $intPartCompare;
        }

        // integer parts are equal, compare fractional part
        return $this->compareBinary($a->getFractionalPart(), $b->getFractionalPart());
    }
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;
    }
1344341
protected function char2hex($a)
    {
        return
            $a >= 48 && $a <= 57 ? $a - 48 : // 0-9
                ($a >= 65 && $a <= 70 ? $a - 55 : // A-F
                    ($a >= 97 && $a <= 102 ? $a - 87 : -1)); // a-f
    }
654565
private function sort($a, $b)
    {
        $result = $this->compareCategories($a->getCategoryId(), $a->getSubcategoryId(), $a->getOrder(), $b->getCategoryId(), $b->getSubcategoryId(), $b->getOrder());

        // if categories are equal, sort by ID
        if (!$result) {
            $aId = $a->getId();
            $bId = $b->getId();

            if ($aId == $bId) {
                return 0;
            }

            return $aId < $bId ? -1 : 1;
        }

        return $result;
    }
466928
public static function compare(string $a, string $b): string
    {
        return static::makeBin($a, 16) === static::makeBin($b, 16);
    }
1327843
public static function compare(Date $a, Date $b): int
    {
        // Get min/max JD for each date.
        switch ($a->qual1) {
            case 'BEF':
                $amin = $a->minimumJulianDay() - 1;
                $amax = $amin;
                break;
            case 'AFT':
                $amax = $a->maximumJulianDay() + 1;
                $amin = $amax;
                break;
            default:
                $amin = $a->minimumJulianDay();
                $amax = $a->maximumJulianDay();
                break;
        }
        switch ($b->qual1) {
            case 'BEF':
                $bmin = $b->minimumJulianDay() - 1;
                $bmax = $bmin;
                break;
            case 'AFT':
                $bmax = $b->maximumJulianDay() + 1;
                $bmin = $bmax;
                break;
            default:
                $bmin = $b->minimumJulianDay();
                $bmax = $b->maximumJulianDay();
                break;
        }
        if ($amax < $bmin) {
            return -1;
        }

        if ($amin > $bmax && $bmax > 0) {
            return 1;
        }

        if ($amin < $bmin && $amax <= $bmax) {
            return -1;
        }

        if ($amin > $bmin && $amax >= $bmax && $bmax > 0) {
            return 1;
        }

        return 0;
    }
341004
public static function cellSort($a, $b)
    {
        sscanf($a, '%[A-Z]%d', $ac, $ar);
        sscanf($b, '%[A-Z]%d', $bc, $br);

        if ($ar == $br) {
            return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
        }
        return ($ar < $br) ? -1 : 1;
    }
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;
        }
    }
1174463
protected function x_or($a, $b)
    {
        $length = strlen($a);
        for($i = 0; $i < $length; $i++) {
            $a[$i] = $a[$i] ^ $b[$i];
        }
        
        return $a;
    }
600180
private function unsignedRightShift($a, $b)
    {
        if ($b >= 32 || $b < -32) {
            $m = (int)($b / 32);
            $b = $b - ($m * 32);
        }

        if ($b < 0) {
            $b = 32 + $b;
        }

        if ($b == 0) {
            return (($a >> 1) & 0x7fffffff) * 2 + (($a >> $b) & 1);
        }

        if ($a < 0) {
            $a = ($a >> 1);
            $a &= 2147483647;
            $a |= 0x40000000;
            $a = ($a >> ($b - 1));
        } else { 
            $a = ($a >> $b);
        }

        return $a;
    }
91857
protected static function _matchLanguage($a, $b) {
		$a = explode('-', strtolower($a));
		$b = explode('-', strtolower($b));

		for ($i = 0, $n = min(count($a), count($b)); $i < $n; $i++) {
			if ($a[$i] !== $b[$i]) {
				break;
			}
		}
		return $i === 0 ? 0 : (float)$i / count($a);
	}
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;
    }