Bug #9645 Updated: usort, uasort, uksort fail every other time
| From: | derick@php.net | Date: | Sat, 28 Apr 2001 19:38:08 +0000 |
| Subject: | Bug #9645 Updated: usort, uasort, uksort fail every other time | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-52769@lists.php.net to get a copy of this message | ||
ID: 9645
Updated by: derick
Reported By: busterb@mail.utexas.edu
Old-Status: Feedback
Status: Closed
Bug Type: Arrays related
PHP Version: 4.0.4pl1
Assigned To:
Comments:
No feedback. If this problem persists with PHP 4.0.5 which
will be released next week, please reopen this report.
Derick
Previous Comments:
---------------------------------------------------------------------------
[2001-03-29 06:12:06] stas@php.net
Could you please provide short self-contained script
demonstrating the problem (including data sample)?
---------------------------------------------------------------------------
[2001-03-09 01:40:12] busterb@mail.utexas.edu
usort, uasort and uksort all fail to sort an array
properly every other time they are called, unless the
array is reset() after each call.
This is a snippet from a class that fails every other time
it is called.
var $sort_field;
function cmp ($a, $b) {
return ($a[$this -> sort_field] > $b[$this ->
sort_field]);
}
function sort_records ($sort_field) {
$this -> sort_field = $sort_field;
uasort ($this -> record_data, array($this, "cmp"));
}
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9645&edit=2