How do I use Comparator to define a custom sort order?

后端 未结 9 1160
生来不讨喜
生来不讨喜 2020-11-22 08:40

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

9条回答
  •  广开言路
    2020-11-22 09:31

    Using just simple loops:

    public static void compareSortOrder (List sortOrder, List listToCompare){
            int currentSortingLevel = 0;
            for (int i=0; i

    And sort order in List

    public static List ALARMS_LIST = Arrays.asList(
                "CRITICAL",
                "MAJOR",
                "MINOR",
                "WARNING",
                "GOOD",
                "N/A");
    

提交回复
热议问题