jdk1.8根据Map的值进行排序的

  • 作者: 凯哥Java(公众号:凯哥Java)
  • 工作小总结
  • 时间:2021-07-21 07:10
  • 2728人已阅读
简介 <, > <, > (<, > aMap) {    <, > = LinkedHashMap<>();    aMap.entrySet() &nb

🔔🔔好消息!好消息!🔔🔔

 如果您需要注册ChatGPT,想要升级ChatGPT4。凯哥可以代注册ChatGPT账号代升级ChatGPT4

有需要的朋友👉:微信号 kaigejava2022

<, > <, > (<, > aMap) {
    <, > = LinkedHashMap<>();
    aMap.entrySet()
            .stream()
            .sorted((p1, p2) -> p2.getValue().compareTo(p1.getValue()))
            .collect(.()).forEach(ele -> .put(ele.getKey(), ele.getValue()));
    ;
}


<, > <, > (<, > aMap) {
    <, > = LinkedHashMap<>();
    aMap.entrySet()
            .stream()
            .sorted((p1, p2) -> p1.getValue().compareTo(p2.getValue()))
            .collect(.()).forEach(ele -> .put(ele.getKey(), ele.getValue()));
    ;
}


TopTop