I have an array of objects. Each object has an attribute we’ll call display_name.
I want to sort this array based on a predefined list of values.
So if the predefined list looks something like this ["Ball", "Cat", "Helicopter", "France"]
Then the objects with the display_name attribute matching "Ball" with be at the head of the list, those with "Cat" second in the list and so on and so forth.
You can use Enumerable#sort_by: