php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #32823 asort orders before uppercase words. a case-insensitive function is needed
Submitted: 2005-04-25 13:59 UTC Modified: 2005-04-26 21:53 UTC
From: asgl at email dot it Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.4 OS: Windows XP Professional SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: asgl at email dot it
New email:
PHP Version: OS:

 

 [2005-04-25 13:59 UTC] asgl at email dot it
Description:
------------
When I order an array with the asort() function, the words that begin with an uppercase letter are ordered before the others.
I think a a case-insensitive would be useful. In fact, in the alphabet there isn't any difference between "A" and "a".
Example:
<?php
$array = array("cat", "Dog", "Mice");
asort($array);
print_r($array);
?>
This returns:

Array
(
    [1] => Dog
    [2] => Mice
    [0] => cat
)

It must return, instead

Array
(
    [0] => cat
    [1] => Dog
    [2] => Mice
)

because "cat" < "Dog" < "Mice".


PS: excuse me for my bad English :)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-25 14:29 UTC] sniper@php.net
Something like natcasesort() perhaps? RTFM..

 [2005-04-26 20:58 UTC] asgl at email dot it
I've already RTFM. I don't want to use that function because I don't want to use the "natural order" algorithm.
In fact, I made a script which can work with both MySQL and textfiles databases. MySQL doesn't support the natural order algorithm in "SELECT" queries, so if I use that function with the textfile-based database the result isn't the same.
 [2005-04-26 21:53 UTC] tony2001@php.net
Then use usort() and implement sort algorithm yourself.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 02:01:28 2024 UTC