JSFiddle - React, Tailwind, and code Playground
JavaScript
const order = ['Plant','Sand','Animal','Grass'];
const unsorted = [{Type: 'Grass', Value: 'Wet'}, {Type: 'Sand', Value: 'Dry'}, {Type: 'Animal', Value: 'Dog'}, {Type: 'Animal', Value: 'Cat'}, {Type: 'Grass', Value: 'Flower'}];
let sorted = unsorted.sort((a,b) => {
let indexA = order.findIndex(type => a.Type === type);
let indexB = order.findIndex(type => b.Type === type);
return (indexA - indexB);
});
console.log(sorted);