If I have a conceptual master list of items ordered by priority/sequence:
1. dog
2. cat
3. fish
4. bunny
5. hamster
And another list comes along with the values
["bunny", "dog", "fish"]
How do I sort the incoming list based on the master list? So, in this example, I would expect the second list to result in
["dog", "fish", "bunny"]
after it has been sorted.
I could manually write a function to implement this, but I feel like Java already would have some sort of built-in and optimized way to do this sort of thing. What is the best way to accomplish this type of list sorting in Java?