Method: a::sort
Sorts a multi-dimensional array by a certain column
Info
Syntax
a::sort($array, $field, $direction='desc', $method=SORT_REGULAR)
Parameters
- $array (array) The source array
- $field (string) The name of the column
- $direction (string) desc (descending) or asc (ascending)
- $method (const) A PHP sort method flag.
Return (array)
The sorted array
Example
$array[0] = array(
'id' => 1,
'username' => 'bastian',
);
$array[1] = array(
'id' => 2,
'username' => 'peter',
);
$array[3] = array(
'id' => 3,
'username' => 'john',
);
$sorted = a::sort($array, 'username ASC');
// Array
// (
// [0] => Array
// (
// [id] => 1
// [username] => bastian
// )
// [1] => Array
// (
// [id] => 3
// [username] => john
// )
// [2] => Array
// (
// [id] => 2
// [username] => peter
// )
// )