Given an array of objects as such –
item= [
{
"id": "1",
"name": "Book",
"price": "100",
"status" : "Disabled"
},
{
"id": "2",
"name": "Pen",
"price": "0",
"status" : "Enabled"
},
{
"id": "3",
"name": "Pencil",
"price": "20",
"status" : "Enabled"
},
{
"id": "4",
"name": "Tape",
"price": "50",
"status" : null
},
{
"id": "5",
"name": "Paper",
"price": "10",
"status" : "Enabled"
},
...
];
if (item.price == '0' || item.status!= 'Enabled'): the item is greyed out.
How can the item be sorted such that the non greyed items are shown first and then the greyed out items
array.sort() works for prices but don’t seem to work for status