Page 1 of 1

sorting an array in date order

Posted: Mon Oct 08, 2007 8:19 am
by Birmingham
hi, can anyone give me a really simple example of sorting an array in date order please? it's strangely an issue i've been struggling with for some time now....

Bubble

Posted: Mon Oct 08, 2007 8:41 am
by N1gel
You could try a bubble sort

Bubble

Posted: Mon Oct 08, 2007 10:25 am
by John Cartwright
Can you post an example array? Specifically, what format are the dates in?

Posted: Mon Oct 08, 2007 11:26 am
by RobertGonzalez
Have you looked at any of the array sorting function in the manual?

Posted: Mon Oct 08, 2007 5:09 pm
by mrkite
Storing your dates in military order "YYYY-MM-DD" will let you sort dates using standard alphabetical sorting.

Posted: Mon Oct 08, 2007 6:17 pm
by RobertPaul
If your dates aren't in YYYY-MM-DD format (which I'm pretty sure is an ISO standard rather than a military standard ;)) then you'll probably want to use usort() with a callback function that decomposes the date string, etc...