PHP 4.0 Bug #6512: sort() Does not sort stings as expected
| From: | jmoore@php.net | Date: | Sun, 03 Sep 2000 11:12:43 +0000 |
| Subject: | PHP 4.0 Bug #6512: sort() Does not sort stings as expected | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-31768@lists.php.net to get a copy of this message | ||
From: jmoore@php.net
Operating system: *
PHP version: 4.0.2
PHP Bug Type: Misbehaving function
Bug description: sort() Does not sort stings as expected
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