Re: sortind arrays

From: Date: Thu, 25 Jan 2007 10:55:12 +0000
Subject: Re: sortind arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-247776@lists.php.net to get a copy of this message
Roman Neuhauser skrev:
# kalles@operamail.com / 2007-01-25 08:12:14 +0200:
How can I sort an array like this so that it would be ASC ordered by the [1] key in subarrays? I need to maintain only the subarray key - value pairs. (Do I make sense?) Array (
    [0] => Array
        (
            [0] => Logo
            [1] => NameC
            [2] => Home
            [3] => url
        )
    [1] => Array
        (
            [0] => Logo
            [1] => NameA
            [2] => Home
            [3] => url
        )
    [2] => Array
        (
            [0] => Logo
            [1] => NameG
            [2] => Home
            [3] => url
        )
}
http://www.php.net/usort I think usort would be a bit overkill, he would probably find himself making a function to sort and maintain the association between the subarrays. Go with array_multisort, it would be a one-liner.


« previous php.general (#247776) next »