This is really a typical case for
Schwartzian Transform or, even better,
Advanced Sorting - GRT - Guttman Rosler Transform. In brief, add at the beginning of your data the date in the YYYYMMDDHHMMSS format, sort it on it, and remove this date when you output the result.