if(typeof(sortOrder) != "boolean"){        
    return items;
}
filtered.sort(function (a, b) {
    if(sortOrder == true){
        return (CustomOrder(a.status) > CustomOrder(b.status) ? 1 : -1);
    }
    else if(sortOrder == false){
        return (CustomOrder(a.status) < CustomOrder(b.status) ? 1 : -1);
    }
});

The status property is a string ("Started", "Running", "Failed", "Finished", etc.), and CustomOrder is a function with a switch that just returns a predefined integer for each string. I switched CustomOrder to just be a simple lookup table object, and the sort call was changed to filtered.sort((a, b) => CustomOrder[a.status] - CustomOrder[b.status]);

By Anonymous, 2017-12-13 00:06:25