So I have a word class and the word class stores both a word and a number, the word being the... well... word and the number being the number of times it occurs in a string. I want to return an array of all the words in alphabetical order and I know that Arrays.sort is a thing but I don't know how to sort the classes themselves.
Could someone help me sort them by both alphabetical order and numerical?
Word class below
import java.io.File;
import java.util.Scanner;
public class Word
{
private String word;
private int count;
public Word(String str)
{
word = str;
count = 1;
}
public String getWord()
{
return word;
}
public int getCount()
{
return count;
}
public void increment()
{
count++;
}
public String toString()
{
String result = String.format(count + "\t" + word);
return result;
}
}