I have a ConcurrentMap<String, Integer>
, and I'd like to get a List<String>
from it with the String mapping to the largest Integer first, second largest second, etc.
Right now I have something along the lines of this:
Loop through the keySet
of the map
In that loop, loop through a "sorted" List<String>
Keep looping until the key String's respective value is less than element i
of the "sorted" List
, and insert it.
Now this will work, but I doubt it's very efficient. Does Java 8 have any built in sorting algorithms that could help me here?