How can I sort an Object with multiple properties based on a specific enum list?
Here is the Object:
const ArratOfobj = [
{ id: 3, ShortType: "LocationWorn", ImageType: "B" },
{ id: 2, ShortType: "SipStillLife", ImageType: "D" },
{ id: 1, ShortType: "SipStillWorn", ImageType: "M" },
{ id: 4, ShortType: "LocationLife", ImageType: "M" },
];
Enum Order
const order= {
'0': { ShortType: "SIP Still Life", ImageType: "M"},
'1': { ShortType: "SIP Still Life", ImageType: "B" },
'2': { ShortType: "Location Still Life", ImageType: "M" },
'3': { ShortType: "Location Still Life", ImageType: "B" }
}
Expected Output
[
{ id: 2, ImageType: "D", ShortType: "SipStillLife" },
{ id: 4, ImageType: "M", ShortType: "LocationLife" },
{ id: 1, ImageType: "M", ShortType: "SipStillWorn" },
{ id: 3, ImageType: "B", ShortType: "LocationWorn" }
]