Java 8 stream map to list of keys sorted by values

前端 未结 6 1276
夕颜
夕颜 2020-12-03 06:29

I have map Map countByType and I want to have a list which has sorted (min to max) keys by their corresponding values. My try is:



        
6条回答
  •  [愿得一人]
    2020-12-03 07:01

    Here is the simple solution with StreamEx

    EntryStream.of(countByType).sortedBy(e -> e.getValue()).keys().toList();
    

提交回复
热议问题