I've implement this sort:
<tbody>
{results.sort((a, b) => a.status > b.status ? 1 : -1).map(el => {
return (
<tr>
<td>{el.id}</td>
<td>{el.amount}</td>
<td>{el.time}</td>
<td>{el.status}</td>
</tr>
);
})}
</tbody>
So now I have them sorted by status as follows: active, updated, waiting. The problem is that I want them sorted by active, waiting, updated. How can I achieve this?
This is my array of objects:
const data = [
{
id: 1,
title: "Order 1",
amount: 3,
status: "active"
},
{
id: 2,
title: "Order 2",
amount: 5,
status: "waiting"
},
{
id: 3,
title: "Order 3",
amount: 4,
status: "updated"
},
{
id: 4,
title: "Order 4",
amount: 3,
status: "active"
}
];