Get minvalue of a Map(Key,Double)

前端 未结 9 1973
一个人的身影
一个人的身影 2020-12-05 07:08

Is there a method (maybe with Google Collections) to obtain the min value of a Map(Key, Double)?

In the traditional way, I would have to sort the map ac

9条回答
  •  盖世英雄少女心
    2020-12-05 07:46

    I'd be inclined to use a Google Collections BiMap:

         String minKey = HashBiMap.create(map).inverse().get(Collections.min(map.values()));
    

    Or something like that (not tested).

提交回复
热议问题