MultiSort
in package
implements
SortCombinator
FinalYes
Enable sorting a record based on multiple column.
The class can be used with PHP's usort and uasort functions.
Tags
Table of Contents
Interfaces
- SortCombinator
- Enable sorting a record based on its value.
Properties
- $sorts : array<string|int, Ordering>
Methods
- __invoke() : int
- The class comparison method.
- all() : self
- append() : self
- Return an instance with the specified sorting algorithm added after the currently registered sorting algorithms.
- prepend() : self
- Return an instance with the specified sorting algorithm added before the currently registered sorting algorithms.
- sort() : Iterator
- Sort an iterable structure with the class comparison method and maintain index association.
- __construct() : mixed
Properties
$sorts read-only
private
array<string|int, Ordering>
$sorts
Methods
__invoke()
The class comparison method.
public
__invoke(mixed $valueA, mixed $valueB) : int
The method must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
Parameters
- $valueA : mixed
- $valueB : mixed
Return values
intall()
public
static all(OrderingExtended ...$sorts) : self
Parameters
- $sorts : OrderingExtended
Return values
selfappend()
Return an instance with the specified sorting algorithm added after the currently registered sorting algorithms.
public
append(OrderingExtended ...$sorts) : self
Parameters
- $sorts : OrderingExtended
Return values
selfprepend()
Return an instance with the specified sorting algorithm added before the currently registered sorting algorithms.
public
prepend(OrderingExtended ...$sorts) : self
Parameters
- $sorts : OrderingExtended
Return values
selfsort()
Sort an iterable structure with the class comparison method and maintain index association.
public
sort(iterable<string|int, mixed> $value) : Iterator
Parameters
- $value : iterable<string|int, mixed>
Return values
Iterator__construct()
private
__construct(OrderingExtended ...$sorts) : mixed
Parameters
- $sorts : OrderingExtended