Re: Multi-Sort -- how to do this?

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

 



On Wed, 2009-06-17 at 22:54 +0100, Douglas Temple wrote:
> ...Sticking my neck out playing with the big boys (and girls) now...
> 
> I assume you've looked at array_multisort() for this, I would think you
> could have multiple arrays being sorted with it (I've only ever used it for
> 2-array sorts). The other option would be to pop all those arrays into a
> single array and use array_multisort()'s ability to sort
> arrays-within-arrays.
> 
> Otherwise Ashley's solution is another possibility; using the keys in the
> sorted $d to dictate where you could place the elements in the other arrays.
> I'd say you could do a nifty loop system which says sequentially read the
> indices in $d and then make a new temp array that is $a, $b or $c (depending
> on which you are sorting) in the sorted order then just name the temp array
> as the original (again, I'd say array_multisort() is fancier than this crude
> but elegant system).
> 
> Finally, why not use quicksort or mergesort for the sorting? Bubblesort is
> inefficient for large lists...

I only mention using a bubblesort as it is the only sorting algorithm i
know! 

Thanks
Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux