为什么我用stream按照某一字段倒叙排序失败,直接用list的sort就可以?
这是代码,distance是double字段,compaing和comparingDouble都用过了
stations.stream().sorted(Comparator.comparingDouble(StationVO::getDistance).reversed()).collect(Collectors.toList());
为什么我用stream按照某一字段倒叙排序失败,直接用list的sort就可以?
这是代码,distance是double字段,compaing和comparingDouble都用过了
stations.stream().sorted(Comparator.comparingDouble(StationVO::getDistance).reversed()).collect(Collectors.toList());
stations = stations.stream().sorted(Comparator.comparingDouble(StationVO::getDistance).reversed()).collect(Collectors.toList());
得接收一下