Documentation

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

ParameterDescriptionVersion
$array
$columns
$callbacks
$defaultValueIfNotSetValueWhen values is not specified, uses $defaultValueIfNotSetValue (any cols)
$preserveKeysWhen false, numerical keys are re-indexed. When true - values are saved.

Exceptions

Example



© «Bitrix24», 2001-2024
Up