So basically I have an array like so:
const data = [
{ name: "John Doe", dob: "2021-07-06T09:45:07.125Z" },
{ name: "Jane Doe", dob: "2021-07-06T09:44:34.121Z" },
{ name: "John Wick", dob: "2021-07-06T09:50:17.313Z" }
];
I need to display this data in a table, so I am mapping through the array and creating a row, but I need the youngest person to be first. I tried doing like .sort()
but couldn't get it to work
{data.sort((a,b) => b.dob- a.dob