sortByColumn
public static \Bitrix\Main\Type\Collection::sortByColumn( array $array, string|array $columns, string|array $callbacks = '', null $defaultValueIfNotSetValue = null, boolean $preserveKeys = false );
Static method sort array by columns.
Abridged record type can be used. For example, Collection::sortByColumn($arr, 'value');
record is equivalent to the record Collection::sortByColumn($arr, array('value' => SORT_ASC))
Example:
Collection::sortByColumn($arr, array('value' => array(SORT_NUMERIC, SORT_ASC), 'attr' => SORT_DESC), array('attr' => 'strlen'), 'www');
Parameters
Parameter | Description | Version |
---|---|---|
$array | ||
$columns | ||
$callbacks | ||
$defaultValueIfNotSetValue | When values is not specified, uses $defaultValueIfNotSetValue (any cols) | |
$preserveKeys | When false, numerical keys are re-indexed. When true - values are saved. |
Exceptions
Example
© «Bitrix24», 2001-2024