I am looking at a redundant list of Strings, e.g.
{ "One", "One", "One", "Two", "Three", "Three" }
What is the best way to count the occurrences, then create a non-redundant list of the strings, sorted by the number of occurrences?
The result I want is a List like this:
{ "One", "Three", "Two" }
You can use the trick in the most voted answer of this question about how to sort the map by its values.
Here is an example implementation (I have added generics to the comparator):