Page 1 of 1

Sorting arrays with mixed elements

Posted: Tue Jun 15, 2010 2:10 pm
by zduniacz
Hi,

I have an array with the following structure: char char integer.

I mean, when I print it get these example results:

POL LIPA 18
USA JOHNSON 21
FRA LIERRE 14

So, I would like this list to be sorted from the highest INT variable to the lowest, so I would get:
USA JOHNSON 21
POL LIPA 18
FRA LIERRE 14

I was able to use sort(); with arrays with the elements of same type but I think it wont work here?

Thanks for all help.

Re: Sorting arrays with mixed elements

Posted: Tue Jun 15, 2010 2:32 pm
by andyhoneycutt
This thread may help you out: viewtopic.php?f=1&t=117537

Re: Sorting arrays with mixed elements

Posted: Wed Jun 16, 2010 7:09 am
by zduniacz
Thanks mate, array_multisort() was exactly what I was looking for.

Re: Sorting arrays with mixed elements

Posted: Wed Jun 16, 2010 9:09 am
by andyhoneycutt
Excellent!