src/Base/ArrayFunctionsTrait.php
public function sort(Closure $callback = null): CollectionInterface
    {
        $array = $this->toArray();

        if (is_null($callback)) {
            sort($array);
        } else {
            usort(
                $array,
                $callback
            );
        }

        return static::make($array);
    }
public function sort(Closure $callback = null): CollectionInterface
    {
        $array = $this->toArray();

        if (is_null($callback)) {
            sort($array);
        } else {
            usort(
                $array,
                $callback
            );
        }

        return static::make($array);
    }
public function sort ( Closure $ callback = null ) : CollectionInterface { $ array = $ this -> toArray ( ) ; if ( is_null ( $ callback ) ) { sort ( $ array ) ; } else { usort ( $ array , $ callback ) ; } return static :: make ( $ array ) ; }
Returns a new sorted collection using a user-defined comparison function.

@param Closure $callback The user-defined comparison function.

@return Collection A new collection instance.
Returns a new sorted collection using a user - defined comparison function .