I have a Record : Record<string, Formulaire>
that is displayed as a list using
Object.keys(obj).map((id) => (
<li> {obj[id].content} - {obj[id].date} </li>
))
But I want this to be displayed ordered by date.
I was expecting the method sort to work on Record and using it like this :
obj.sort((a,b) => ((a.date > b.date) ? 1 : -1))
but object don't have sort
method, so what is the best way of sorting this array before displaying it ?
I saw this question : Sort JavaScript object by key but my problem is different as I'm working with a typescript Record and I want it to be displayed by on the propertie associated with each key and not by the key itself.
A solution given bellow is actually ordering the list of keys using a property of the object associated with that key.