I am want to sort messages where both important equals 1 and read equals 0 to be put at the beginning of the array.
I have an array of these message objects:
{
archived: 0
draftMode: 0
entry_date: "Mar 22, 2022"
important: 1
message: "Hello world"
messageId: 1
pinned: 0
read: 0
subject: "test"
}
The code I am using to sort is:
messages.sort((a, b) => (a.important > b.important && a.read < b.read ? -1 : 1))