JSFiddle - React, Tailwind, and code Playground
by 3gwebtrain
JavaScript
const dates = ['01 Mar 2017', '01 Mar 2019'];
dates.sort(function(a,b, i){
// Turn your strings into dates, and then subtract them
// to get a value that is either negative, positive, or zero.
console.log(i);
});
const formatted = [];
dates.forEach((item, i) => {
formatted[i] = new Date(item);
})
console.log( dates );