I am working on a school project than involves me making a program than takes a String an counts how many times all the words in the String appear. I have managed to do that, through making to arrays. One array is the String array and it holds the words and other Integer array that holds the number of times a word appear. A specific word and how many times it appears have the same element number in the two arrays.
But my problem is sorting them in decending order, I thought at first that I could do it by using this line of code:
Arrays.sort(thenumbers, Collections.reverseOrder());
But I realised that this would sort the number of times a words appears but that would ruin the whole program because the words and the numbers would have different element number in the arrays.
Is there a way to fix this?
Any help would be appreciated, thanks!