Req #6512 [Ana->Bgs]: sort() Does not sort stings as expected
| From: | johannes@php.net | Date: | Fri, 06 Aug 2010 23:43:06 +0000 |
| Subject: | Req #6512 [Ana->Bgs]: sort() Does not sort stings as expected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-153186@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=6512&edit=1
ID: 6512
Updated by: johannes@php.net
Reported by: jmoore@php.net
Summary: sort() Does not sort stings as expected
-Status: Analyzed
+Status: Bogus
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: *
PHP Version: 4.0.2
Block user comment: N
New Comment:
Expected behavior.
Previous Comments:
------------------------------------------------------------------------
[2000-09-03 08:35:55] jmoore@php.net
OK Chaning to feature/change request and reopening. (The function isnt
really misbehaving...)
------------------------------------------------------------------------
[2000-09-03 08:31:45] waldschrott@php.net
well, natcasesort() does this for natural sorting, but
regular/string/numeric sorting can´t be sorted cased...
not sure if it should be closed...
------------------------------------------------------------------------
[2000-09-03 08:26:36] jmoore@php.net
natcasesort() and natsort() do this, I will add a see also for
natcasesort to sort.
------------------------------------------------------------------------
[2000-09-03 07:21:36] waldschrott@php.net
I´d vote for adding another option to all sorting functions,
like SORT_CASED, maybe the bit way
asort($x,SORT_STRING|SORT_CASED)
------------------------------------------------------------------------
[2000-09-03 07:12:43] jmoore@php.net
When using sort, it sorts by ASCII code and not alphabetically, this
might be what was intended but the function does not behave as might be
expected, take the following example:
<?php
$test = array("AA","AC","AR","AJ","Ab");
asort($test);
var_dump($test);
?>
Does not ourput
AA,Ab,AC,AJ,AR
But infact
AA,AC,AJ,AR,Ab
Now this is due to Ascii Char codes. Perhaps a warning should be added
to the manual if this behaviour stays the same.
James
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=6512&edit=1