I have a collection of Incidents (displayed as an array below) that I need to sort meticulously by State, Priority, and Start_date. Specifically, I want them ordered in the sequence of Initial > Ongoing > InReview > Resolved for State, then Priority should be P1 > P2 > P3, and finally within each priority level sorted by Start_date from oldest to newest.
Despite searching online, I haven't been able to find any examples of such a detailed sorting requirement. Does anyone have suggestions on how I can achieve this?
Below is the representation of my incidents in an array:
$scope.Incidents= [{
Start_date: "2021-12-01 09:20:00"
State: "Initial"
Priority: "P1"
},{
Start_date: "2021-11-01 07:20:00"
State: "Ongoing"
Priority: "P2"
},{ Start_date: "2021-10-01 05:20:00"
State: "Resolved"
Priority: "P3"
},{ Start_date: "2021-12-01 09:48:00"
State: "Ongoing"
Priority: "coach"
},{ Start_date: "2021-11-20 06:55:00"
State: "InReview"
Priority: "P1"
},{ Start_date: "2021-08-01 09:20:00"
State: "InReview"
Priority: "P2"
}];
<div ng-repeat="incident in Incidents | orderBy:Custom_order">
<div>{{incident.Priority}} - {{incident.Priority}} - {{incident.Start_date}}</div>
</div>