SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Array Sorting

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Fixed] Array Sorting

    Hi

    If i have

    array("Bc", "AA", "a", "z");

    how can i order them as follows:

    a, AA, Bc, z

    sort, gives: AA, Bc, a, z
    natcasesort gives: z, a, Bc, AA

    Thanks
    Last edited by xylar; Apr 28, 2009 at 03:44.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    $a = array("Bc""AA""a""z");
    natcasesort$a );
    var_dump($a); 
    gives me

    array
    2 => string 'a' (length=1)
    1 => string 'AA' (length=2)
    0 => string 'Bc' (length=2)
    3 => string 'z' (length=1)

    win32/php5.2.6

    ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •