#26412 [Opn->Bgs]: natsort ignores extra white space
ID: 26412
Updated by: iliaa@php.net
Reported By: phpbug at reuben dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Mac OS X
PHP Version: 4.3.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
' ' is 10 and 'b' is 98, make your own conclustions.
Previous Comments:
------------------------------------------------------------------------
[2003-11-25 14:02:05] phpbug at reuben dot com
Description:
------------
natsort (and related functions like strnatcmp) appear to
collapse all white space chars into just one space, so
that 'a a' sorts at the same level as 'a a' (so the
order of the returned sort is not determined), while it
should sort one before the other (which one is more
"natural" is up for discussion, but it shouldn't
randomly return one or the
other).
Reproduce code:
---------------
$array = array('a b','a a','a a','aa','a
b','ab');
natsort($array);
echo "<pre>";
foreach ($array as $val)
echo "$val\n";
echo "</pre>";
Expected result:
----------------
Should print:
aa
ab
a a
a b
a a
a b
-OR-
aa
a a
a a
ab
a b
a b
Actual result:
--------------
Actually prints (changes order if you change order in
array definition):
aa
a a
a a
ab
a b
a b
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26412&edit=1
Thread (3 messages)