anvil/striker-ui/components/Anvils/sortAnvils.ts

15 lines
478 B
TypeScript
Raw Normal View History

2021-04-27 23:09:37 +00:00
const sortAnvils = (unsortedList: AnvilListItem[]): AnvilListItem[] => {
const optimal: AnvilListItem[] = [];
const notReady: AnvilListItem[] = [];
const degraded: AnvilListItem[] = [];
unsortedList.forEach((anvil) => {
if (anvil.anvil_state === 'optimal') optimal.push(anvil);
else if (anvil.anvil_state === 'not_ready') notReady.push(anvil);
else degraded.push(anvil);
});
return [...degraded, ...notReady, ...optimal];
};
export default sortAnvils;