java stream 多字段排序
我觉得最实用的当属这种原形:
var comparator= Comparator.comparing((SocietyMember x)->x.getSocietyId()) .thenComparing(x-> studentMap.get(x.getStudentUuid()).getMatchedOrgUuid()) .thenComparing(x->studentMap.get(x.getStudentUuid()).getMatchedGradeUuid()) .thenComparing(x->studentMap.get(x.getStudentUuid()).getMatchedClassUuid()); members.sort(comparator);
懂的自然懂,代码没经过精简,是项目中实际代码
桂棹兮兰桨,击空明兮溯流光。