Re: Sorting multi-dimensional array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You should be able to achieve this quite simply with a user sort:

usort($input, 'mysort');

function mysort($a, $b) {
    return ($a['counter'] > $b['counter']) ? 1 : -1;
}

--
Rajesh

--- In php-objects@xxxxxxxxxxxxxxx, Francisco - São Paulo - Brazil
<avs1001@...> wrote:
>
> I have this array:
> 
> Array
> (
>     [0] => Array
>         (
>             [account] => 263
>             [counter] => 1
>         )
> 
>     [1] => Array
>         (
>             [account] => 324
>             [counter] => 5
>         )
> 
>     [2] => Array
>         (
>             [account] => 972
>             [counter] => 3
>         )
> 
>     [3] => Array
>         (
>             [account] => 1316
>             [counter] => 3
>         )
> 
>     [4] => Array
>         (
>             [account] => 1380
>             [counter] => 1
>         )
> 
>     [5] => Array
>         (
>             [account] => 1880
>             [counter] => 2
> 	)
> )
> 
> I need to sort by the key [counter], how can I do that?





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux