{
//对集合就行排序的时候报错
List<CityRainInfoExcelVO> sortList = voList.stream().sorted(Comparator.comparing(CityRainInfoExcelVO::getRainfall).reversed()).collect(Collectors.toList());
// CityRainInfoExcelVO类中实现了Comparable接口,重写了compareTo方法
@Override
public int compareTo(@NotNull CityRainInfoExcelVO o) {
return rainfall.compareTo(o.getRainfall());
}
java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.xxx.xxx.xxx.common.VO.CityRainInfoExcelVO
at java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
at java.util.Collections$ReverseComparator2.compare(Collections.java:5232)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.util.TimSort.sort(TimSort.java:234)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:348)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:483)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)