Sort an array using a case insensitive "natural order" algorithm.

@return static
164216
public function natcasesort(): Collection
    {
        $index = 0;
        $items = $this->items;

        foreach ($items as &$item) {
            $item = [$index++, $item];
        }

        uasort($items, function ($a, $b) {
            $result = strnatcasecmp($a[1], $b[1]);

            return $result === 0 ? $a[0] - $b[0] : $result;
        });

        foreach ($items as &$item) {
            $item = $item[1];
        }

        return new static($items);
    }
1254829
public static function sortRecursive($array)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                $value = static::sortRecursive($value);
            }
        }

        if (static::isAssoc($array)) {
            ksort($array);
        } else {
            sort($array);
        }

        return $array;
    }
46878
public function doSort()
    {
        $this->sorted = array();

        foreach ($this->elements as $element) {
            $parents = array();
            $this->visit($element, $parents);
        }

        return $this->sorted;
    }
1166516
public static function orderBy(): array
    {
        $args = \func_get_args();
        $data = array_shift($args);
        foreach ($args as $n => $field) {
            if (\is_string($field)) {
                $tmp = [];
                foreach ($data as $key => $row) {
                    $tmp[$key] = $row[$field];
                }
                $args[$n] = $tmp;
            }
        }
        $args[] = &$data;
        array_multisort($args);
        return array_pop($args);
    }
784105
protected function sortHaystack()
    {
        $sorted_haystack = [];
        foreach ($this->haystack as $string) {
            $sorted_haystack[$string] = $this->levenshteinUtf8($this->needle, $string);
        }

        // Apply threshold when set.
        if(!is_null($this->threshold)){
            $sorted_haystack = array_filter($sorted_haystack, function ($score){
                return $score <= $this->threshold;
            });
        }

        asort($sorted_haystack);

        $this->sorted_haystack = $sorted_haystack;
    }
1135389
public function sort(Sorting $sorting)
	{
		if (is_callable($sorting->getSortCallback())) {
			call_user_func(
				$sorting->getSortCallback(),
				$this->data_source,
				$sorting->getSort()
			);

			return $this;
		}

		$sort = $sorting->getSort();

		if (!empty($sort)) {
			foreach ($sort as $column => $order) {
				$this->data_source->addOrderBy($this->checkAliases($column), $order);
			}
		} else {
			/**
			 * Has the statement already a order by clause?
			 */
			if (!$this->data_source->getDQLPart('orderBy')) {
				$this->data_source->orderBy($this->checkAliases($this->primary_key));
			}
		}

		return $this;
	}
678558
public function sort(array $sort = null) {
        if ($sort === null) {
            return $this->sort;
        }

        $this->sort = $sort;

        return $this;
    }
57304
@SafeVarargs
    public static <V extends Comparable<V>> V[] sort(V... array) {
        Arrays.sort(array);
        return array;
    }
155740
public function sort()
    {
        return function (\SplFileInfo $a, \SplFileInfo $b) {
            preg_match(self::PATTERN, $a->getFileName(), $version_a);
            preg_match(self::PATTERN, $b->getFileName(), $version_b);
            return ((int)$version_a[1] < (int)$version_b[1]) ? -1 : 1;
        };
    }
469192
public function sort()
    {
        usort(
            $this->items,
            function ($a, $b) {
                if ($a[0] === $b[0]) {
                    return 0;
                }
                return $a[0] < $b[0] ? -1 : 1;
            }
        );
    }
1052073
public function sort()
    {
        foreach ($this->idDirectedGraph as $nodeId => $successorIds) {
            if (!isset($this->nodeMarks[$nodeId])) {
                $this->visit($nodeId);
            }
        }

        $sortedIdList = array_reverse($this->sortedIdList);

        $sortedNodeList = [];
        foreach ($sortedIdList as $nodeId) {
            $sortedNodeList[] = $this->idToNode[$nodeId];
        }

        return $sortedNodeList;
    }
82986
protected function _sort()
    {
        if (!isset($this->_sorts) || count($this->_sorts) === 0) {
            return;
        }

        $columns      = $this->_dataGrid->getActiveColumnsOrdered();
        $sorts        = $this->_sorts;
        $sortPosition = $this->_sortPositions;

        usort($this->_output, function ($a, $b) use ($columns, $sortPosition, $sorts) {
            foreach ($sortPosition as $colIndex) {
                $sort = $sorts[$colIndex];
                /** @var $sort\RBM\Datagrid\Data\Sort */
                /** @var $column\RBM\Datagrid\Column */
                $column = $columns[$colIndex];
                $valueA = $column->getSortData($a);
                $valueB = $column->getSortData($b);

                if ($valueA == $valueB) {
                    continue;
                }

                $arr = array($valueA, $valueB);

                $args = array_merge(array(&$arr), array($sort->getDirection(), $sort->getType()));
                call_user_func_array('array_multisort', $args);

                return ($arr[0] == $valueA) ? -1 : 1;
            }
            return 0;
        });
    }
1140782
public function lcfirst(){
		
		if($this->isNullOrWhitespace()){
			return clone $this;
		}
		else if($this->count() === 1){
			return new static(\mb_strtolower($this->_Value, $this->_Encoding), $this->_Encoding);
		}
		
		$str = $this[0]->lcfirst() . $this->substring(1);
		
		return new static($str, $this->_Encoding);
		
	}
511472
protected function parseSorting(){
		$order = array();
		foreach($this->stmt->getSorting() as $rule){
			list($field, $type) = $rule;
			$order[] = $this->tryDelimite($field) . ($type !== null ? ' ' . $type : '');
		}
		return "\nORDER BY " . implode(', ', $order);
	}
1103211
public function sortedSetOf(): self
    {
        $obj = clone $this;
        usort($obj->_elements,
            function (Element $a, Element $b) {
                $a_der = $a->toDER();
                $b_der = $b->toDER();
                return strcmp($a_der, $b_der);
            });
        return $obj;
    }
211902
public function sort( bool $desc = false )
	{
		$items = $this->items;
		asort($items);
		if($desc)
		{
			$items = array_reverse($items, true);
		}
		return new static($items);
	}
609689
public function OrderByItem()
    {
        $this->lexer->peek(); // lookahead => '.'
        $this->lexer->peek(); // lookahead => token after '.'

        $peek = $this->lexer->peek(); // lookahead => token after the token after the '.'

        $this->lexer->resetPeek();

        $glimpse = $this->lexer->glimpse();

        switch (true) {
            case $this->isFunction():
                $expr = $this->FunctionDeclaration();
                break;

            case $this->isMathOperator($peek):
                $expr = $this->SimpleArithmeticExpression();
                break;

            case $glimpse['type'] === Lexer::T_DOT:
                $expr = $this->SingleValuedPathExpression();
                break;

            case $this->lexer->peek() && $this->isMathOperator($this->peekBeyondClosingParenthesis()):
                $expr = $this->ScalarExpression();
                break;

            default:
                $expr = $this->ResultVariable();
                break;
        }

        $type = 'ASC';
        $item = new AST\OrderByItem($expr);

        switch (true) {
            case $this->lexer->isNextToken(Lexer::T_DESC):
                $this->match(Lexer::T_DESC);
                $type = 'DESC';
                break;

            case $this->lexer->isNextToken(Lexer::T_ASC):
                $this->match(Lexer::T_ASC);
                break;

            default:
                // Do nothing
        }

        $item->type = $type;

        return $item;
    }