src/Bag.php
public function sortBy(callable $iteratee, $order = SORT_ASC, $preserveKeys = false)
    {
        return $this->sortWith($this->iterateeToComparator($iteratee, $order === SORT_ASC), $preserveKeys);
    }
public function sortBy(callable $iteratee, $order = SORT_ASC, $preserveKeys = false)
    {
        return $this->sortWith($this->iterateeToComparator($iteratee, $order === SORT_ASC), $preserveKeys);
    }
Returns a bag with the values sorted based on the `$iteratee` function.

Example:

$bag = Bag::from([
['name' => 'Bob'],
['name' => 'Alice'],
]);

// Sort values by "name" property
$bag->sortBy(function ($item) {
return $item['name'];
});
// => Bag of [
//     ['name' => 'Alice']
//     ['name' => 'Bob']
// ]

@param callable $iteratee     Function given `($value)`
@param int      $order        `SORT_ASC` or `SORT_DESC`
@param bool     $preserveKeys Whether to preserve keys for maps or to re-index for lists

@return static