note 51850 added to function.usort
| From: | steve at tracorp dot com | Date: | Tue, 12 Apr 2005 23:57:30 +0000 |
| Subject: | note 51850 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87920@lists.php.net to get a copy of this message | ||
When sorting a large multi-dimensional array, I ran into an issue where the array was not being
sorted either ascending or descending, even when it started in sorted order. It turns out that the
above note about the callback function returning an integer is true. My comparison function was
just a subtraction between two floating point numbers, and the result being a float produced very
unpredictable results.
----
Manual Page -- http://www.php.net/manual/en/function.usort.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51850
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51850&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51850&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51850&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51850&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51850&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51850&report=yes
Search -- http://master.php.net/manage/user-notes.php