Re: Sorting multidim array and keeping associations
| From: | Peter Lauri | Date: | Sat, 11 Dec 2004 08:04:14 +0000 |
| Subject: | Re: Sorting multidim array and keeping associations | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-204035@lists.php.net to get a copy of this message | ||
Stupid as I was, I did not do what I should have done :) In the origin the
array was created from a MySQL database. I did not sort it correctly from
there because I did not have the knowledge about the GROUP BY command, so I
tried to solve it via PHP. Now I have everything sorted and alright just by
making the Query correct.
/Peter
"Peter Lauri" <peter@lauri.se> skrev i meddelandet
news:20041117143429.53342.qmail@pb1.pair.com...
> Best groupmember,
>
> I have an multidim array that looks something like this:
>
> [40] => [1]=32, [2]=>55, ["total"]=>87
> [22] => [8]=2, [7]=>105, ["total"]=>107
> [142] => [2]=3, [7]=>8, ["total"]=>11
>
> I want to sort this array according to the "total" and still keep the acc.
> with the basekey. I know I can easily do this by writing an function
myself.
> But are there any built in functions for this? I have looked at usort,
> uksort and more, but they do not seem to solve my problem.
>
> - Best Of Times
> /Peter