I'm trying to sort the date from this array of objects from the latest to the oldest. I'm trying this code, i.e. copy the array to a new const and then use it with sort, but I have the same result, no sorted date. My code is below:
const array=[...user?.editedBy]
console.log(array,"array")
const sortedDates = array?.sort((dateA, dateB) => dateB.date -dateA.date )
console.log(sortedDates,'sortedArray')
The first pic is the console log from the array and the second from sortedDates.
So the same result, can someone please help me figure out what I'm missing?
Thank you in advance

