note 28154 added to function.usort
| From: | php_dev at rack1 dot php dot net | Date: | Sat, 04 Jan 2003 01:59:30 +0000 |
| Subject: | note 28154 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41641@lists.php.net to get a copy of this message | ||
Encountered a bug in 4.1.2 on Sun:
usort crashes (Apache error 500) when I am trying to sort a multi-dimensional array with same values
using this sort function:
function my_sort($a, $b)
{ return ($a[1] > $b[1]) ? -1 :1 ;
}
/*here, $a and $b single-dim arrays which are elements oof the multi-dim array being sorted by
usort. 1 is the string field that I am actually sorting by*/
Work around:
function by_name($a, $b)
{
return ($a[2] >= $b[2]) ? -1 :1 ;
}
:)
Hope this saves somebody time.
--
http://www.php.net/manual/en/function.usort.php
http://master.php.net/manage/user-notes.php?action=edit+28154
http://master.php.net/manage/user-notes.php?action=delete+28154
http://master.php.net/manage/user-notes.php?action=reject+28154