Sort
class Sort extends ArrayMutator (View source)
Sorts an array. The callback is used to retrieve the value to sort by. If no callback is provided, the value itself is used.
Preserves key association by default. To reset key association, set $preserveKeys
to false.
Supports built-in PHP sorting flags. See https://www.php.net/manual/en/function.sort.php for more information.
Methods
__construct(SortDirection $direction = SortDirection::Asc, callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
No description
static Sort
asc(callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
Sorts an array in ascending order.
static Sort
desc(callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
Sorts an array in descending order.
static Sort
make(SortDirection $direction = SortDirection::Asc, callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
No description
array
mutateArray(array $array)
No description
Details
__construct(SortDirection $direction = SortDirection::Asc, callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
No description
static Sort
asc(callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
Sorts an array in ascending order.
static Sort
desc(callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
Sorts an array in descending order.
static Sort
make(SortDirection $direction = SortDirection::Asc, callable $callback = null, bool $preserveKeys = true, int $flags = SORT_REGULAR)
No description
mixed
mutate(mixed $value)
Mutate the input value.
protected array
mutateArray(array $array)
No description