Sort multi-dimensional array .
App::Utility()->multiArraySort(Data, Field, Sort Type)
Parameter |
Description |
---|---|
Data |
An array of data |
Field |
Field Name to sort |
Sort Type |
Sorting type ASC or DESC |
See bellow example:
$data = array(
array("id"=> 5, "name"=> "Jahan"),
array("id"=> 1, "name"=> "Khan"),
array("id"=> 4, "name"=> "Regan"),
array("id"=> 10, "name"=> "Tamzum")
);
$list = App::Utility()->multiArraySort($data, 'id', 'DESC');
pre($list);
/*
Return
Array
(
[0] => Array
(
[id] => 10
[name] => Tamzum
)
[1] => Array
(
[id] => 5
[name] => Jahan
)
[2] => Array
(
[id] => 4
[name] => Regan
)
[3] => Array
(
[id] => 1
[name] => Khan
)
)
*/