I'm looking for a simple way to not only filter but also reorder an array of objects so that that outcoming formats are filtered and sorted in the right order. Here's an example array
[{
"id": "4",
"fileName": "fileXX",
"format": "mp3"
}, {
"id": "5",
"fileName": "fileXY",
"format": "aac"
}
}, {
"id": "6",
"fileName": "fileXZ",
"format": "opus"
}
}]
The array may be longer and contain different formats but the goal is to always only allow mp3 and aac and have aac come first in the array. Result for this example would be
[{
"id": "5",
"fileName": "fileXY",
"format": "aac"
}
},{
"id": "4",
"fileName": "fileXX",
"format": "mp3"
}]
alphabetical sorting should be avoided as the desired order may change later.
right orderfor filtering and sorting