lithium\data\Collection::sort PHP Method

sort() public method

Overriden to load any data that has not yet been loaded.
See also: lithium\util\Collection::sort()
public sort ( string | callable $field = 'id', array $options = [] ) : lithium\data\Collection
$field string | callable The field to sort the data on, can also be a callback to a custom sort function.
$options array Reserved for future use.
return lithium\data\Collection Returns itself.
    public function sort($field = 'id', array $options = array())
    {
        $this->offsetGet(null);
        if (is_string($field)) {
            $sorter = function ($a, $b) use($field) {
                if (is_array($a)) {
                    $a = (object) $a;
                }
                if (is_array($b)) {
                    $b = (object) $b;
                }
                return strcmp($a->{$field}, $b->{$field});
            };
        } elseif (is_callable($field)) {
            $sorter = $field;
        } else {
            return $this;
        }
        return parent::sort($sorter, $options);
    }