note 68450 deleted from function.array-multisort by cmb
| From: | cmb@php.net | Date: | Sun, 29 Sep 2019 07:43:25 +0000 |
| Subject: | note 68450 deleted from function.array-multisort by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212415@lists.php.net to get a copy of this message | ||
Note Submitter: KES
----
It is very handy to have function, which sort like this:
$arrayToSort[]= array(0 => ".", "type" => "dir");
$arrayToSort[]= array(0 => "qf", "type" => "file");
$arrayToSort[]= array(0 => "..", "type" => "dir");
$arrayToSort[]= array(0 => "text.txt", "type" => "file");
$arrayToSort[]= array(0 => "hello", "type" => "dir");
//first sort by the column 'type', then sort by the column '0'
$howToSort= array('type'=> 'asc', 0=> 'desc');
multisort($arrayToSort, $howToSort);
The result:
0 | type
----------------------------
. | dir
.. | dir
hello | dir
text.txt | file
qf | file