Bootstrap

java通过Comparator比较器对集合进行多属性连续分组内升降排序,以及null空值排最前或最后

一、排序数据准备,分别对 one、two、three 三个属性进行连续分组内排序

        @Data
        @AllArgsConstructor
        class Aa {
            private Long id;
            private Integer one;
            private Integer two;
            private String three;
        }
		
        List<Aa> aaList = ListUtil.toList(
                null,
                new Aa(1L, 1, 1, "1"),
                new Aa(2L, 1, 3, "2"),
                new Aa(3L, 1, 3, "1"),
                new Aa(4L, 1, 2, "2"),
                new Aa(5L, 1, null, "1"),
                new Aa(6L, 1, 2, "3"),

                new Aa(7L, 2, 2, "1"),
                new Aa(8L, 2, 1, "1"),

                new Aa(9L, 3, 2, "1"),
                new Aa(10L, 3, 1, ""),
                new Aa(11L, null, 1, "8"),
                new Aa(12L, 3, 3, "2")
        );

;