java - Convert Map to Sorted List -


I try to convert a map to an ordered list Based on the values ​​in the map

Suppose I have the following:

  Maps & lt; String, integer & gt; Map = maps.newHashMap (); Map.put ("foo", 1); Map.put ("boo", 3); Map.put ("bar", 2); // List integer value - List of ASC or DESC & lt; String & gt; List = // elegant guava call? The list should be: {foo, bar, boo}    

  list & lt ; String & gt; List = ordering Natural (). OnResultOf (functions .map) .sortcopy (map.keySet ());   

... I think?

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -