Re: Multi-Sort -- how to do this?
| From: | Ashley Sheridan | Date: | Thu, 18 Jun 2009 20:26:15 +0000 |
| Subject: | Re: Multi-Sort -- how to do this? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294294@lists.php.net to get a copy of this message | ||
On Thu, 2009-06-18 at 13:04 -0400, tedd wrote:
> > > Ash:
> >>
> >> You missed the point. I could use the built-in sort (i.e., sort() )
> >> and sort the $d array. However, I would like the indexes of the other
> >> arrays to match the new sort.
> >>
> >> Cheers,
> >>
> > > tedd
> > >
> >I think I might need a for-instance here, as you lost me!
> >
> >Thanks
> >Ash
>
>
> Ash:
>
> You can sort any array by using the "built-in" php function sort() -- try it.
>
> After you try it, you'll find that the array is sorted but the order
> of the values are not as they were before. In other words, the
> index-value pairs are different. Here's an example:
>
> http://www.webbytedd.com/bbbb/sort/
>
> Before the sort, the value 'red' is located in the $a array under index 0
>
> After the sort, the value 'red' is still in the $a array but under
> index 2. Note, the values of the indexes have changed.
>
> My query was simply how to sort one array (order it) while ordering
> the values of other arrays in the same manner.
>
> The multisort() function does that as seen here:
>
> http://www.webbytedd.com/bbbb/multisort/
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com
> http://ancientstones.com
> http://earthstones.com
>
I know about the sort() function, I just didn't fully understand the
question. I guess that's what late nights can do to ya!
Thanks
Ash
www.ashleysheridan.co.uk