note 59900 added to function.array-multisort
| From: | phuatkungphu at osu1 dot php dot net | Date: | Mon, 19 Dec 2005 19:36:32 +0000 |
| Subject: | note 59900 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100422@lists.php.net to get a copy of this message | ||
Notepad's example using asort/arsort will -not- work unless 'points' is defined
-before- 'name'.
Running the posted code sorts by 'name', which was not the point of the previous posts.
Defining 'points' as 'apoints' also did not work; however, defining
'points' first yields correct sorting:
$test[0]['points']=1;
$test[0]['name']='Peter';
$test[1]['points']=5;
$test[1]['name']='Mike';
$test[2]['points']=2;
$test[2]['name']='John';
asort($test);
It appears asort uses the first defined element to sort a multidimensional array.
----
Manual Page -- http://www.php.net/manual/en/function.array-multisort.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59900
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59900&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59900&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59900&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59900&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59900&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59900&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59900&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59900&report=yes
Search -- http://master.php.net/manage/user-notes.php