I'm trying to rearrange my ArrayList by a specific string. so I'd like to rearrange my list by giving a priority to the type "truck" than the type "sedan" or the type "SUV". Technically, I could use reverseorder from their alphabetical order but I'd like to implement where a specific string itself has the priority. For example, if I have a list of cars in random order as following,
ArrayList<Car> cars = new ArrayList<Car>(Arrays.asList(
new Car("1", "truck"),
new Car("2", "sedan"),
new Car("3", "SUV"),
new Car("4", "truck"),
new Car("5", "truck"));
so that my ideal order should be 1,4,5,2,3. I appreciate any ideas!