//置顶升序,时间降序
msgRecommendedVideoSys.stream().sorted(Comparator.comparing(a -> a.getStick()).thenComparing(a -> a.getTime(),Comparator.reverseOrder()));
//置顶降序,时间升序
msgRecommendedVideoSys.stream().sorted(Comparator.comparing(a -> a.getStick(),Comparator.reverseOrder()).thenComparing(a -> a.getTime()));
//置顶降序,时间降序
msgRecommendedVideoSys.stream().sorted(Comparator.comparing(a -> a.getStick(),Comparator.reverseOrder()).thenComparing(a -> a.getTime(),Comparator.reverseOrder()));
Stream流根据多字段排序,有优先级
最新推荐文章于 2024-08-05 15:39:32 发布