I have an array structured like this:
let myarr =
[{id:1 , name: "mark" , birthday: "1990-08-18"},
{id:2 , name: "fred" , birthday: "1990-08-17"},
{id:3 , name: "franck" , birthday: "1990-08-16"},
{id:4 , name: "mike" , birthday: "1990-08-15"},
{id:5 , name: "jean" , birthday: "1990-08-17"}]
I am currently sorting these objects by their "birthday"
myarr.sort((a, b) => new Date(b.birthday).getTime() - new Date(a.birthday).getTime());
However, there are instances where two objects have the same birthday value. In these cases, I would like the sort function to prioritize the object with the higher "id".
Any suggestions on how to achieve this?