Recently, I've been diving into APIs and managed to create a table using pure vanilla javascript along with a long list of sorting commands that can filter the table based on strings.
My goal is to establish an object containing strings in a specific order for filtering purposes. For instance, let's say we're dealing with "rarity" in a video game. By using this filter, I envision creating a sorting function that will organize the content in the table according to the specified filter sequence.
The desired order would be: Common > Uncommon > Rare > Epic > Legendary
To achieve this, it seems like you would provide the function with the key to compare among each "item" in the dataset.
let filter = {
"COMMON",
"UNCOMMON",
"RARE",
"EPIC",
"LEGENDARY"
}
What approach do you suggest for solving this challenge?