src/Collection/ArrayCollection.php
public function sort(callable $comparator = null): ArrayCollection
    {
        $items = $this->items;

        $comparator ? uasort($items, $comparator) : uasort($items, function ($a, $b) {
            return $a <=> $b;
        });

        return new static($items);
    }
public function sort(callable $comparator = null): ArrayCollection
    {
        $items = $this->items;

        $comparator ? uasort($items, $comparator) : uasort($items, function ($a, $b) {
            return $a <=> $b;
        });

        return new static($items);
    }
public function sort ( callable $ comparator = null ) : ArrayCollection { $ items = $ this -> items ; $ comparator ? uasort ( $ items , $ comparator ) : uasort ( $ items , function ( $ a , $ b ) { return $ a <=> $ b ; } ) ; return new static ( $ items ) ; }
Creates a sorted collection

Comparator signature:

<code>
function ($a, $b): int {}
</code>

@param callable|null $comparator The comparator function

@return ArrayCollection
Creates a sorted collection