|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-06 14:32 UTC] kae at verens dot com
Description:
------------
natsort, which sorts arrays using natural language, does not understand numbers which begin with '0'.
Reproduce code:
---------------
<?php
$arr= array('test012','test01','test02');
natsort($arr);
var_dump($arr);
Expected result:
----------------
array
1 => string 'test01' (length=6)
2 => string 'test02' (length=6)
0 => string 'test012' (length=7)
Actual result:
--------------
array
1 => string 'test01' (length=6)
0 => string 'test012' (length=7)
2 => string 'test02' (length=6)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 11:00:02 2025 UTC |
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) }