note 19037 added to function.array-multisort
| From: | yann at nouvelle-vie dot com | Date: | Wed, 13 Feb 2002 19:23:11 +0000 |
| Subject: | note 19037 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26574@lists.php.net to get a copy of this message | ||
If you want to sort a multidimentionnal array based on a certain row, the easiest way I found was
using usort() and a comparison function of my own.
The comparison function is called with two elements of the array. Then, in the function, as the two
elements are also arrays (we are dealing with a multidimentionnal one), the comparison can be made
on any row:
if ($a[2] > $b[2]) return 1; ...
See the definition of usort() for that.
--
http://www.php.net/manual/en/function.array-multisort.php
http://master.php.net/manage/user-notes.php?action=edit+19037
http://master.php.net/manage/user-notes.php?action=delete+19037
http://master.php.net/manage/user-notes.php?action=reject+19037