I am facing a challenge in sorting some data based on date. The dates are currently stored as strings in the format dd-mm-yyyy.
To address this, I created a filter that converted the plain string of numbers from the US date format to the UK date format, for example, 01272012 to 27-01-2014. However, I encountered an issue where the ordering was still treating them as numeric strings, causing dates like 01-01-1990 to come before 02-01-2014.
Does anyone have any suggestions on how to properly sort this data using a filter?
Thank you!
Update
I discovered that the dates would be automatically sorted if formatted as yyyy-mm-dd. Therefore, I used orderBy:['date']
to arrange the data while continuing to utilize my original filter when displaying it.
In order to display the most recent dates first, I had to reverse the data by adding a -
to my orderBy statement: orderBy:['-date']
.