I did short testing and apparently you can convert the string of date to an actual date object and then using the getTime method to retrieve its time in milliseconds since 1970. You could sort this number i assume
let date= new Date(`2021-03-14T16:41:45.577Z`)
i suppose you should be able to think your code from here
Just to be clear, the format of “2021-03-14T16:41:45.577Z” is an ISO 8601 datetime string. It is sortable as it because the longer durations come first and it’s military time. It goes year, month, day, hour (24-hour), minute, second, milliseconds. It doesn’t need to be formatted for sorting. The only problem would be if the dates were in different timezones, but the “Z” at the end means that it is “Zulu” or universal time, in other words Greenwich Mean Time.
That is what allows lasjorg’s answer to work. If you had it in some non-“biggest-to-smallest” format (e.g. “12/31/2020”) then that wouldn’t work and would need some kind of conversion to either a string that works (like the ISO string) or convert it to a numerical value like Sylvant is talking about. (Or would need a more complicated sorting function.)
But if you know that you will always be getting UTC ISO datetime strings, the lasjorg’s answer is what you need, just doing a simple sort and telling it off of which property to sort and how - in this case fairly simple.