When using a lambda function, the solution worked well for me. However, due to some failed karma test cases, I had to refrain from using lambda functions in sorting. I am currently facing issues on how to tackle this problem, as the code below is not producing the desired results.
var test=[{ID: "91",Name: "sgtue", standardID: "1"},
{ID: "41",Name: "asdfasdf", standardID: "2"},
{ID: "5", Name: "credd", standardID: "2"},
{ID: "2",Name: "dddawer", standardID: "2"},
{ID: "2",Name: "dsfadf", standardID: "3"},
{ID: "275", Name: "xcvcvc", standardID: "201"}
];
var groupOrder = [1,3,2,201];
var testSorted = test.sort(function (a, b) {groupOrder.indexOf(parseInt(a.standardID))-groupOrder.indexOf(parseInt(b.standardID))});
console.log(testSorted);
The same logic can be viewed at the following link: Live Example
In addition, you can find my related question on Stack Overflow here: How to customize grouping in AngularJS from array of objects