PHP Класс YaLinqo\OrderedEnumerable

Наследование: extends Enumerable
Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( Enumerable $source, integer | boolean $sortOrder, integer $sortFlags, boolean $isReversed, callable $keySelector, callable $comparer, OrderedEnumerable $parent = null )
getIterator ( )
thenBy ( callable | null $keySelector = null, callable | integer | null $comparer = null ) : OrderedEnumerable

Syntax: thenBy ([{{(v, k) ==> key} [, {{(a, b) ==> diff}]])

Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.

thenByDescending ( callable | null $keySelector = null, callable | integer | null $comparer = null ) : OrderedEnumerable

Syntax: thenByDescending ([{{(v, k) ==> key} [, {{(a, b) ==> diff}]])

Performs a subsequent ordering of the elements in a sequence in descending order according to a key.

thenByDir ( integer | boolean $sortOrder, callable | null $keySelector = null, callable | integer | null $comparer = null ) : OrderedEnumerable

Syntax: thenByDir (false|true [, {{(v, k) ==> key} [, {{(a, b) ==> diff}]])

Performs a subsequent ordering of elements in a sequence in a particular direction (ascending, descending) according to a key.

Приватные методы

Метод Описание
getSingleComparer ( )
sortByMultipleFields ( $array, $canMultisort )
sortIterator ( $orders, $canMultisort )
sortIteratorWithMultisort ( &$enum, $orders )
sortIteratorWithUsort ( &$enum, $orders )
trySortArrayWithMultisort ( $array, $orders, $canMultisort )
trySortBySingleField ( $array, $canMultisort )

Описание методов

__construct() публичный Метод

public __construct ( Enumerable $source, integer | boolean $sortOrder, integer $sortFlags, boolean $isReversed, callable $keySelector, callable $comparer, OrderedEnumerable $parent = null )
$source Enumerable
$sortOrder integer | boolean A direction in which to order the elements: false or SORT_DESC for ascending (by increasing value), true or SORT_ASC for descending (by decreasing value).
$sortFlags integer Sort flags for array_multisort.
$isReversed boolean Whether comparer result needs to be negated (used in usort).
$keySelector callable {(v, k) ==> key} A function to extract a key from an element.
$comparer callable {(a, b) ==> diff} Difference between a and b: <0 if a<b; 0 if a==b; >0 if a>b
$parent OrderedEnumerable

getIterator() публичный Метод

public getIterator ( )

thenBy() публичный Метод

Three methods are defined to extend the type OrderedEnumerable, which is the return type of this method. These three methods, namely {@link thenBy}, {@link thenByDescending} and {@link thenByDir}, enable you to specify additional sort criteria to sort a sequence. These methods also return an OrderedEnumerable, which means any number of consecutive calls to thenBy, thenByDescending or thenByDir can be made.

Because OrderedEnumerable inherits from {@link Enumerable}, you can call {@link Enumerable::orderBy orderBy}, {@link Enumerable::orderByDescending orderByDescending} or {@link Enumerable::orderByDir orderByDir} on the results of a call to orderBy, orderByDescending, orderByDir, thenBy, thenByDescending or thenByDir. Doing this introduces a new primary ordering that ignores the previously established ordering.

This method performs an unstable sort; that is, if the keys of two elements are equal, the order of the elements is not preserved. In contrast, a stable sort preserves the order of elements that have the same key. Internally, {@link usort} is used.

public thenBy ( callable | null $keySelector = null, callable | integer | null $comparer = null ) : OrderedEnumerable
$keySelector callable | null {(v, k) ==> key} A function to extract a key from an element. Default: value.
$comparer callable | integer | null {(a, b) ==> diff} Difference between a and b: <0 if a<b; 0 if a==b; >0 if a>b. Can also be a combination of SORT_ flags.
Результат OrderedEnumerable

thenByDescending() публичный Метод

Three methods are defined to extend the type OrderedEnumerable, which is the return type of this method. These three methods, namely {@link thenBy}, {@link thenByDescending} and {@link thenByDir}, enable you to specify additional sort criteria to sort a sequence. These methods also return an OrderedEnumerable, which means any number of consecutive calls to thenBy, thenByDescending or thenByDir can be made.

Because OrderedEnumerable inherits from {@link Enumerable}, you can call {@link Enumerable::orderBy orderBy}, {@link Enumerable::orderByDescending orderByDescending} or {@link Enumerable::orderByDir orderByDir} on the results of a call to orderBy, orderByDescending, orderByDir, thenBy, thenByDescending or thenByDir. Doing this introduces a new primary ordering that ignores the previously established ordering.

This method performs an unstable sort; that is, if the keys of two elements are equal, the order of the elements is not preserved. In contrast, a stable sort preserves the order of elements that have the same key. Internally, {@link usort} is used.

public thenByDescending ( callable | null $keySelector = null, callable | integer | null $comparer = null ) : OrderedEnumerable
$keySelector callable | null {(v, k) ==> key} A function to extract a key from an element. Default: value.
$comparer callable | integer | null {(a, b) ==> diff} Difference between a and b: <0 if a<b; 0 if a==b; >0 if a>b. Can also be a combination of SORT_ flags.
Результат OrderedEnumerable

thenByDir() публичный Метод

Three methods are defined to extend the type OrderedEnumerable, which is the return type of this method. These three methods, namely {@link thenBy}, {@link thenByDescending} and {@link thenByDir}, enable you to specify additional sort criteria to sort a sequence. These methods also return an OrderedEnumerable, which means any number of consecutive calls to thenBy, thenByDescending or thenByDir can be made.

Because OrderedEnumerable inherits from {@link Enumerable}, you can call {@link Enumerable::orderBy orderBy}, {@link Enumerable::orderByDescending orderByDescending} or {@link Enumerable::orderByDir orderByDir} on the results of a call to orderBy, orderByDescending, orderByDir, thenBy, thenByDescending or thenByDir. Doing this introduces a new primary ordering that ignores the previously established ordering.

This method performs an unstable sort; that is, if the keys of two elements are equal, the order of the elements is not preserved. In contrast, a stable sort preserves the order of elements that have the same key. Internally, {@link usort} is used.

public thenByDir ( integer | boolean $sortOrder, callable | null $keySelector = null, callable | integer | null $comparer = null ) : OrderedEnumerable
$sortOrder integer | boolean A direction in which to order the elements: false or SORT_DESC for ascending (by increasing value), true or SORT_ASC for descending (by decreasing value).
$keySelector callable | null {(v, k) ==> key} A function to extract a key from an element. Default: value.
$comparer callable | integer | null {(a, b) ==> diff} Difference between a and b: <0 if a<b; 0 if a==b; >0 if a>b. Can also be a combination of SORT_ flags.
Результат OrderedEnumerable