I'm currently working with angular 10
and I need help figuring out how to 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 }
]
My goal is to order the array based on the boolean value of state
, like this:
[
{ state: true, id: 2 },
{ state: true, id: 4 },
{ state: false, id: 1 },
{ state: false, id: 3 },
{ state: false, id: 5 }
]
I want the true
values to come before the false
values in the sorted array.
Could someone advise me on which property or feature in TypeScript can help me achieve this?
Thank you for your assistance!