I am using angular 10 and I was wondering how can I sort this array
var dic = [
{ state: false, id: 1 },
{ state: true, id: 2} ,
{ state: false, id: 3 },
{ state: true, id: 4 },
{ state: false, id: 5 }
]
I want to sort by the value of the boolean state, so the result goes this way:
[
{ state: true, id: 2 },
{ state: true, id: 4 },
{ state: false, id: 1 },
{ state: false, id: 3 },
{ state: false, id: 5 }
]
The true value goes first in the array.
What property or something from typescript I have to use to do that?
Thank you!