ID: 44929
Updated by: [email protected]
Reported By: kae at verens dot com
-Status: Closed
+Status: Assigned
Bug Type: Arrays related
-Operating System: Linux
+Operating System: *
-PHP Version: 5.2.6
+PHP Version: 5.*, 6CVS (2009-05-02)
Assigned To: rasmus
New Comment:
This fails now (in both 32bit and 64bit systems):
# php -r '$a = array(.0001, .0021, -.01, -1, 0, .09, 2, -.9, 33);
natcasesort($a); var_dump($a);'
array(9) {
[2]=>
float(-0.01)
[7]=>
float(-0.9)
[3]=>
int(-1)
[4]=>
int(0)
[0]=>
float(0.0001)
[5]=>
float(0.09)
[1]=>
float(0.0021)
[6]=>
int(2)
[8]=>
int(33)
}
Previous Comments:
------------------------------------------------------------------------
[2009-04-08 18:11:28] [email protected]
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Fixed in CVS
------------------------------------------------------------------------
[2009-04-08 15:17:37] bax_70 at hotmail dot com
Excuseme bad example
the right one
$a[0]="00001";
$a[1]="00008";
$a[2]="00005";
$a[3]="000011";
$a[4]="00003";
$a[5]="000014";
natsort($a);
print_r($a);
Array ( [0] => 00001 [3] => 000011 [5] => 000014 [4] => 00003 [2] =>
00005 [1] => 00008 )
------------------------------------------------------------------------
[2009-04-08 14:35:44] bax_70 at hotmail dot com
Bad result.
$a[0]=00001;
$a[1]=00008;
$a[2]=00005;
$a[3]=000011;
$a[4]=00003;
$a[5]=000014;
natsort($a);
print_r($a);
Array ( [1] => 0 [0] => 1 [4] => 3 [2] => 5 [3] => 9 [5] => 12 )
------------------------------------------------------------------------
[2008-08-27 08:41:25] [email protected]
Checking this further, this patch messes up the order of "0" in an
array that contains negative values like "-123", so it still needs some
work.
------------------------------------------------------------------------
[2008-08-27 07:53:46] [email protected]
I was hoping for some feedback on the patch to hear if it actually
fixes it.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/44929
--
Edit this bug report at http://bugs.php.net/?id=44929&edit=1