src/DS/Traits/TraitSequence.php
public function sorted(?callable $comparator = null): Sequence
    {

        $items = $comparator ?
            $this->items->sorted($comparator) :
            $this->items->sorted();

        return $this->duplicate($items);
    }
public function sorted(?callable $comparator = null): Sequence
    {

        $items = $comparator ?
            $this->items->sorted($comparator) :
            $this->items->sorted();

        return $this->duplicate($items);
    }
public function sorted ( ? callable $ comparator = null ) : Sequence { $ items = $ comparator ? $ this -> items -> sorted ( $ comparator ) : $ this -> items -> sorted ( ) ; return $ this -> duplicate ( $ items ) ; }
Returns a sorted copy of the sequence, based on an optional callable
comparator. Natural ordering will be used if a comparator is not given.

@param callable|null $comparator Accepts two values to be compared.
Should return the result of a <=> b.

@return \PlanB\DS\Sequence
Returns a sorted copy of the sequence based on an optional callable comparator . Natural ordering will be used if a comparator is not given .