|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-11-25 15:40 UTC] iliaa@php.net
[2003-11-25 16:22 UTC] jpatrin at pnicorp dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 01:00:01 2025 UTC |
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