I have a list of dates (ranging from 2007 to 2012) in the DD/MM/YYYY format and I need to sort this list.
My problem is, when I simply use Sort[]
I get:
{"01/02/2007", "01/02/2008", "01/02/2009", "01/02/2010", "01/02/2011",...}
However, I need to sort this list to get something like:
{"02/01/2007", "03/01/2007", "06/01/2007", "08/01/2007", "10/01/2007",...}
After reading the StackExchange Mathematica forum I got the following code:
Flatten[SortBy[
Partition[
Table[DateString[
datelist[[v]], {"Day", "/", "Month", "/", "Year"}], {v, 1,
Dimensions[datelist][[1]]}], 1],
AbsoluteTime[{#[[1]], {"Day", "Month", "Year"}}] &]]
It works... However, it takes almost 2 seconds to compute, and, worst, I get 4 error messages:
DateString::ambig: Warning: the interpretation of the string 02/01/2007 as a date is ambiguous. >>
DateString::ambig: Warning: the interpretation of the string 10/04/2012 as a date is ambiguous. >>
DateString::ambig: Warning: the interpretation of the string 09/04/2012 as a date is ambiguous. >>
General::stop: Further output of DateString::ambig will be suppressed during this calculation. >>
Is there any way to sort this list faster without getting error messages?