note 31130 added to function.array-multisort
| From: | php at richardNOSPAMneillPLEASE dot org dot uk | Date: | Thu, 10 Apr 2003 17:48:51 +0000 |
| Subject: | note 31130 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46456@lists.php.net to get a copy of this message | ||
Array of Arrays are equivalent to many 1-D arrays with the same key.
I got very confused by trying to sort an array of arrays. I had an array $myarray[$i][$j] which I
wanted to sort in the i direction according to the value of $myarray[$i][0]. It took a long time to
realise that doing it this way is extremely muddled! It is much easier to have two arrays, as per
the post of Richard on 13 March 2002.
Using his example, I had an array $people, each of whose elements was a 2-element array
{participant-name, score} This is, in fact, equivalent, and at first, more obvious, but it's
the *wrong* way to do it!
--
http://www.php.net/manual/en/function.array-multisort.php
http://master.php.net/manage/user-notes.php?action=edit+31130
http://master.php.net/manage/user-notes.php?action=delete+31130
http://master.php.net/manage/user-notes.php?action=reject+31130