Data Structure to sort elements by values

I need a Data structure in java that can manupilate Strings, compute the frequency of each word in an ArrayList(of Strings) and then i need to sort it based on the frequencies. To put it simply the Data structure needs to be an associative array that can be sorted , i already put it in a Hashmap and and got surprised to the fact that it can’t be sorted , now i’m stuck thinking about another data structure . ps: (using two lists is not suited to my program because it needs to do a lot of calculations , so it would be better if a single structure holds each String and its occurence instead of a list for the Strings and the occurence ).Thanks in advance.


Source: java

Leave a Reply