From:             phpbug at reuben dot com
Operating system: Mac OS X
PHP version:      4.3.3
PHP Bug Type:     Arrays related
Bug description:  natsort ignores extra white space

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 bug report at http://bugs.php.net/?id=26412&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26412&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26412&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26412&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26412&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26412&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26412&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26412&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26412&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26412&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26412&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26412&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26412&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26412&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26412&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26412&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26412&r=float

Reply via email to