I have a immutable map and I am trying to sort based on the two properties. For example, The format of the data I have:
const items = [
{id:1,created:2020:12:12T10:12:56,start:2020:12:10},
{id:1,created:2020:12:12T10:12:58,start:2020:12:09},
{id:1,created:2020:12:12T10:12:57,start:2020:12:08},
{id:1,created:2020:12:12T10:12:53,start:2020:12:09},
]
I want to sort that items based on the two properties "created" and "start". I can probably do that:
const sorted = items.sort((a, b) => new Date(b.get('created')) - new Date(a.get('created')));
Is there any way I can sort together with the start property as well like:
const sorted = items.sort((a, b) => new Date(b.get('created')) - new Date(a.get('created')) && new Date(b.get('start')) - new Date(a.get('start')) );
Is that correct or does anybody know a good approach to accomplish that. Thanks in Advance