java sorting list using data from key/value
Posted on 2012-03-15
I'm kinda in struggle here.
So I have a class Word which would just return Strings (but needed it for the equals method to equalsIgnoreCase())
I also have a WordScores class which containc a key/value collections of Words and scores (scores being the score of how much the word is being used)
Now in the WordScores class I have a method: sortByScore(java.util.List<Word> words)
the meaning would be to sort the list words by scores of the key/value collection. Also when the score is the same it should be sorted alphabetically.
Now I'm not sure what collection type to use for the key/value pair...
Also I hoped Collections.sort(words) would work to first sort it alphabetically but doesn't work as it doesn't know its a collection of objects containing only Strings.