I want to develop a sorting demo for car list. I am using data table to display car list. Now actually I want to sort the list by car color. Here it is not sort by alphabeti
I will do something like this:
List order = List.of("Red", "Green", "Magenta", "Silver"); Comparator.comparing(Car::getColor(), Comparator.comparingInt(c -> order.indexOf(c)))
All credits go to @Sean Patrick Floyd :)