I have array of object contain date format. code works only for ordering the day not for months and years
My Code
const bills = [
{
name: "ghaith",
type: "transport",
date: "12 may 21",
},
{
name: "Alex",
type: "Restaurants",
date: "15 oct 20",
}
];
bills.sort((a, b) => b.date < a.date ? 1 : -1)
bills.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime())... which of cause works for valid date shorthand formats only ... the OP e.g. did provide originally"12 mai 21"whereas it should be"12 may 21"... it's fixed/edited already.