note 68450 added to function.array-multisort
| From: | KES at osu1 dot php dot net | Date: | Thu, 27 Jul 2006 11:35:21 +0000 |
| Subject: | note 68450 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115247@lists.php.net to get a copy of this message | ||
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
----
Server IP: 195.248.191.91
Probable Submitter: 82.207.99.31
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-multisort.php
Edit -- http://master.php.net/note/edit/68450
Del: integrated -- http://master.php.net/note/delete/68450/integrated
Del: useless -- http://master.php.net/note/delete/68450/useless
Del: bad code -- http://master.php.net/note/delete/68450/bad+code
Del: spam -- http://master.php.net/note/delete/68450/spam
Del: non-english -- http://master.php.net/note/delete/68450/non-english
Del: in docs -- http://master.php.net/note/delete/68450/in+docs
Del: other reasons-- http://master.php.net/note/delete/68450
Reject -- http://master.php.net/note/reject/68450
Search -- http://master.php.net/manage/user-notes.php