lithium\util\Collection::sort()

public method

Sorts the objects in the collection.

Parameters

  • string|callable $sorter

    The sorter for the data. Either a callable to use as the sort function or a string with the name of a well-known sort function like 'natsort' or a compare function like 'strcmp'. Defaults to 'sort'.

  • array $options

    Reserved for future use.

Returns

Collection

Returns itself.

Source

	public function sort($sorter = 'sort', array $options = []) {
		if (is_string($sorter) && strpos($sorter, 'sort') !== false && is_callable($sorter)) {
			call_user_func_array($sorter, [&$this->_data]);
		} elseif (is_callable($sorter)) {
			usort($this->_data, $sorter);
		}
		return $this;
	}