I want to sort an array of objects and looks like this:
[
{
"id": 1,
"businessEntityId": "BE001",
"financials": {
"Npbt": 2323,
"Interest": 123213,
"Depreciation": 213123,
"Ebit": 1312321,
"EbitDa": 123123,
"Leasing": 123213
},
"type": "Actual",
"startDate": "2018-06-15T00:00:00.000Z",
"endDate": "2018-06-15T00:00:00.000Z",
"model": "Commercial",
"duration": 12,
"quality": "Unqualified"
},
{
"id": 2,
"businessEntityId": "BE002",
"financials": {
"Npbt": 2323,
"Interest": 123213,
"Depreciation": 213123,
"Ebit": 1312321,
"EbitDa": 123123,
"Leasing": 123213
},
"type": "Actual",
"startDate": "2017-06-15T00:00:00.000Z",
"endDate": "2017-06-15T00:00:00.000Z",
"model": "Agribusiness",
"duration": 12,
"quality": "Audited"
},
]
I know how do a basic sort for like sort by date but the requirements are a bit tougher. These are the sortingrules in desc. order of priority:
Modeltype: 1.Commercial 2.Agribusiness
If modeltype is Commercial the rules are: 1.Type : Actual and order of quality:Unqualified,Qualified,Unaudited. 2.Type: Projected and order of quality:Projection, Audited.
If modeltype is Aggribusiness the rules are: 1.Type : Historical and order of quality:Unqualified,Qualified,Unaudited. 2.Type: Actual and order of quality:Projection, Audited.
Like I said no straighforward sort but can anyone help me to get on the right path / how would I begin to solve this?