javascript - Custom sorting on multiple fields in Angularjs -
i have requirement sort ng-repeat list based on 2 fields:
1> status : red, orange, green.
2> date: (older present date)
the sorting should such red, orange , last green
below json:
{ "data": [ {"name": "john", "startdate": "14,feb,2015", "status": "orange"}, {"name": "john1", "startdate": "18,feb,2015", "status": "red"}, {"name": "john2", "startdate": "28,feb,2015", "status": "red"}, {"name": "john3", "startdate": "14,feb,2015", "status": "red"}, {"name": "john4", "startdate": "19,feb,2015", "status": "orange"}, {"name": "john5", "startdate": "15,feb,2015", "status": "green"}, {"name": "john6", "startdate": "21,feb,2015", "status": "red"} ] }
i want above json sorted below:
{ "data": [ {"name": "john3", "startdate": "14,feb,2015", "status": "red"}, {"name": "john1", "startdate": "18,feb,2015", "status": "red"}, {"name": "john6", "startdate": "21,feb,2015", "status": "red"}, {"name": "john2", "startdate": "28,feb,2015", "status": "red"}, {"name": "john5", "startdate": "15,feb,2015", "status": "green"}, {"name": "john", "startdate": "14,feb,2015", "status": "orange"}, {"name": "john4", "startdate": "19,feb,2015", "status": "orange"} ] }
Comments
Post a Comment