Re: sorting a multidimensional array
| From: | Andrei Zmievski | Date: | Wed, 20 Dec 2000 14:05:51 +0000 |
| Subject: | Re: sorting a multidimensional array | ||
| References: | 1 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-726@lists.php.net to get a copy of this message | ||
On Wed, 20 Dec 2000, michel guilhem wrote:
> I try to sort an array called $info which is tridimensional , the first
> value is the number of elements , the second value is used for the sort
> ( name of the variable ) and the third is a positionnal value for
> elements multivaluated .
> What can i do to sort under an element in second position without losing
> the link beetwen the others elements
>
> example
> Before the sort i have
>
> $info[0]["el"][0] = 120 and info[0]["el1"][0] = cou1
> $info[1]["el"][0] = 100 and info[1]["el1"][0] = cou2
> $info[2]["el"][0] = 110 and info[2]["el1"][0] = cou3
> $info[3]["el"][0] = 140 and info[3]["el1"][0] = cou4
>
> My purpose is to sort with ["el"] and the values of ["el1"] remains
> linked
>
> $info[0]["el"][0] = 100 and info[0]["el1"][0] = cou2
> $info[1]["el"][0] = 110 and info[1]["el1"][0] = cou3
> $info[2]["el"][0] = 120 and info[2]["el1"][0] = cou1
> $info[3]["el"][0] = 140 and info[3]["el1"][0] = cou4
>
> What can i do ?
Maybe try this:
array_multisort($info[0]["el"], SORT_NUMERIC, $info[0]["el1"]);
-Andrei
The main reason Santa is so jolly is because he knows where
all the bad girls live. -- George Carlin