I'd like to sort a list of task by status, for example, tasks with status "active" should be grouped follow by tasks with completed, and then tasks with other status should be displayed in the order they were added:
it should display something like this:
const taskToShows = [
{task: "task7", status: "active"},
{task: "task6", status: "active"},
{task: "task5", status: "active"},
{task: "task8", status: "completed"},
{task: "task4", status: "completed"},
{task: "task1", status: "pending"},
{task: "task2", status: "other status"},
{task: "task3", status: "progress"},
]
My Approach was using sort() I can ordered at first but then it ordered all the tasks, and just need the actives and the completed ones at the top and All other tasks in the order added by the user
if(this.status === 'active' || this.status === 'completed'){
this.tasksToShow = this.tasksList.sort((a, b) => (a.status.toLowerCase() >
b.status.toLowerCase()) ? 1 : (a.status.toLowerCase() === b.status.toLowerCase() )
? ((a.status > b.status) ? 0 : -1) : -1 )
}