Looking for a way to sort an object array in Angular 16+ based on status. The desired status order is:
[N-Op, Used, Unknown, Op]
Here's the sample data:
const stockList = [
{
'heading': 'SK',
'status': 'N-Op',
},
{
'heading': 'SKU',
'status': 'Op',
},
{
'heading': 'Uniliver',
'status': 'Op',
},
{
'heading': 'Bugati',
'status': 'Unknown',
},
{
'heading': 'Bugati',
'status': 'N-Op',
},
];
How can I achieve the expected result as shown below?
const stockList = [
{
'heading': 'SK',
'status': 'N-Op',
},
{
'heading': 'Bugati',
'status': 'N-Op',
},
{
'heading': 'Bugati',
'status': 'Unknown',
},
{
'heading': 'SKU',
'status': 'Op',
},
{
'heading': 'Uniliver',
'status': 'Op',
}
];