Hi, I have some code that sorts an array of dates that I first convert into YYYYDDMM format with sort($ISOSDates, SORT_NUMERIC). What I need to do is add a piece of data to each to each date array that is being sorted before it's sorted. So if I have an array sortedDateData that has dates added to it like this:
sortedDateData[$i] = array($year$monthNum$dayNum, $mediaId).
how can I sort the array by $year$monthNum$dayNum?
So the new sortedDateData[0][0] would have the first date
then sortedDateData[1][0] would have the next date
thanks,
4dplane
Sort 2D array by date
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Sort 2D array by date
I don't think you're going to get a proper sort using YYYYDDMM, but it depends upon what you want.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Re: Sort 2D array by date
why dont you convert them to unix timestamps then sort them as you add them to your list?