Internal callback funtion for sorting of group objects.

@param  Node $a
@param  Node $b
@return integer
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;
  }
311556
protected function compareNodes($a, $b)
    {
        $typeA = (isset($a['{DAV:}resourcetype']))
            ? (in_array('{DAV:}collection', $a['{DAV:}resourcetype']->getValue()))
            : false;

        $typeB = (isset($b['{DAV:}resourcetype']))
            ? (in_array('{DAV:}collection', $b['{DAV:}resourcetype']->getValue()))
            : false;

        // If same type, sort alphabetically by filename:
        if ($typeA === $typeB) {
            return strnatcasecmp($a['displayPath'], $b['displayPath']);
        }

        return ($typeA < $typeB) ? 1 : -1;
    }
11353
function sortGroups(selector) {
  selector.each((subSelector) => {
    subSelector.nodes.sort((a, b) => {
      // different types cannot be sorted
      if (a.type !== b.type) {
        return 0;
      }

      // sort alphabetically
      return a.value < b.value ? -1 : 1;
    });
  });

  selector.sort((a, b) => (a.nodes.join('') < b.nodes.join('') ? -1 : 1));
}
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 );
    }
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;
    }
436879
protected function sortGroupsByPriority(
        SecondaryMenuGroupInterface $a,
        SecondaryMenuGroupInterface $b
    ) {
        $a = $a->priority();
        $b = $b->priority();

        if ($a === $b) {
            return 0;
        }
        return ($a < $b) ? (-1) : 1;
    }
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;
  }
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;
    }
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;
	}
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;
    }
258064
private static function sortByAuthor($a, $b, $i = 0)
    {
        $first = $a;
        $second = $b;

        if (isset($a[$i])) {
            $first = $a[$i];
        }

        if (isset($b[$i])) {
            $second = $b[$i];
        }

        if ($first == $a && $second == $b && $first['name'] == $second['name']) {
            return 1;
        } elseif ($first['name'] == $second['name']) {
            return self::sortByAuthor($a, $b, $i + 1);
        } else {
            return ($first['name'] < $second['name']) ? -1 : 1;
        }
    }
200564
public static function sort_items($a, $b)
	{
		$a_date = $a->get_date('U');
		$b_date = $b->get_date('U');
		if ($a_date && $b_date) {
			return $a_date > $b_date ? -1 : 1;
		}
		// Sort items without dates to the top.
		if ($a_date) {
			return 1;
		}
		if ($b_date) {
			return -1;
		}
		return 0;
	}
1050255
public function urlSort($a, $b)
    {
        $result = 0;
        foreach ([$a, $b] as $key => $url) {
            if (parse_url($url, PHP_URL_SCHEME) === 'https') {
                $result += $key === 0 ? -2 : 2;
            }
        }
        $result += strlen($a) <= strlen($b) ? -1 : 1;

        return $result;
    }
1192834
function compareIndex(nodeA, nodeB) {
  var indexA = nodeA && nodeA.sortIndex;
  var indexB = nodeB && nodeB.sortIndex;
  if (!indexA && !indexB) {
    return 0;
  }
  else if (Boolean(indexA) !== Boolean(indexB)) {
    return indexA ? +1 : indexB ? -1 : 0;
  }
  else {
    return indexA - indexB;
  }
}
948069
public function sort_by_many_fields($a, $b) {
        foreach ($this->sortfields as $field => $mult) {
            // Nulls first.
            if (is_null($a->$field) && !is_null($b->$field)) {
                return -$mult;
            }
            if (is_null($b->$field) && !is_null($a->$field)) {
                return $mult;
            }

            if (is_string($a->$field) || is_string($b->$field)) {
                // String fields.
                if ($cmp = strcoll($a->$field, $b->$field)) {
                    return $mult * $cmp;
                }
            } else {
                // Int fields.
                if ($a->$field > $b->$field) {
                    return $mult;
                }
                if ($a->$field < $b->$field) {
                    return -$mult;
                }
            }
        }
        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;
    }
1024289
public function call($a, $b)
    {
        return $a * ($b / $this->gcdMath->call($a, $b));
    }