2018년 5월 27일 일요일

java8 sort

// ソート
List<InfoBean> userCpDepList = new ArrayList<InfoBean>();
Comparator<InfoBean> orderByItem1 = Comparator.comparing(InfoBean::getItem1).reversed();
Comparator<InfoBean> orderByItem2 = Comparator.comparing(InfoBean::getItem2);
Comparator<InfoBean> orderByItem3 = Comparator.comparing(InfoBean::getItem3);

userCpDepList = userCpDepList.stream()
.sorted(orderByItem1
.thenComparing(orderByItem2
.thenComparing(orderByItem3))).collect(Collectors.toList());

댓글 없음:

댓글 쓰기