I have got an ArrayList with 500+ words in. I'm trying to organise them into a list where the word that appears the most is at the top and then the 2nd most frequent and so on.
So far I've managed to filter out words with a frequency of less than 5 with the code below however I cannot work out how I can organise these results into a list of their frequencies in descending order.
Set<String> unique = new HashSet<String>(wordsL);
for (String key : unique) {
if (Collections.frequency(wordsL, key) > 5) {
// println(Collections.frequency(wordsL, key));
lwords.add(key);
println(lwords);
}
}
Thanks in advance for any help.