note 19037 deleted from function.array-multisort by aidan
| From: | aidan@php.net | Date: | Sun, 03 Oct 2004 10:59:24 +0000 |
| Subject: | note 19037 deleted from function.array-multisort by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77815@lists.php.net to get a copy of this message | ||
Note Submitter: yann at nouvelle-vie dot com
----
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.