public function sortWith(callable $comparator, $preserveKeys = false)
    {
        $items = $this->items;

        $preserveKeys ? uasort($items, $comparator) : usort($items, $comparator);

        return $this->createFrom($items);
    }
public function sortWith(callable $comparator, $preserveKeys = false)
    {
        $items = $this->items;

        $preserveKeys ? uasort($items, $comparator) : usort($items, $comparator);

        return $this->createFrom($items);
    }
Returns a bag with the values sorted with the `$comparator`.

@param callable $comparator   Function given `($itemA, $itemB)`
@param bool     $preserveKeys Whether to preserve keys for maps or to re-index for lists

@return static