usort won't work anymore on 408dev
| From: | Marc Boeren | Date: | Thu, 04 Oct 2001 10:02:26 +0000 |
| Subject: | usort won't work anymore on 408dev | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-67254@lists.php.net to get a copy of this message | ||
Hi,
In the latest CVS, usort gives strange results: if I use the example from
the manual,
function cmp ($a, $b) {
if ($a == $b) return 0;
return ($a < $b) ? -1 : 1;
}
$a = array (3, 2, 5, 6, 1);
usort ($a, "cmp");
while (list ($key, $value) = each ($a)) {
echo "$key: $value\n";
}
I would expect to get
0: 1
1: 2
2: 3
3: 5
4: 6
This still works on 407RC3
However, on the latest CVS I get:
4: 1
1: 2
0: 3
2: 5
3: 6
So it seems the results are sorted, but the keys aren't reassigned...
Cheerio, Marc.