import java.io.File;
import java.util.Scanner;
public class MainClass {
public static Winner [] listOfWinners;
public static void loadFromFile()
{
try{
//Create instance of Scanner and provide instance of File pointing to the txt file
Scanner input = new Scanner(new File("WorldSeriesWinners.txt"));
//Get the number of teams
int years = input.nextInt();
input.nextLine();//move to the next line
//Create the array
listOfWinners = new Winner[years];
//for every year in the text file
for(int index = 0; index<years; index++)
{
//Get the year
int year = input.nextInt();
input.skip(" ");
//Get the team
String team = input.nextLine();
//Create an instance of Winner and add it to the next spot in the array
listOfWinners[index] = new Winner(team,year);
}
}catch(Exception e)
{
System.out.println("Something went wrong when loading the file!");
System.out.println(e.toString());
System.exit(0);
}
}
public static void sortByTeamName()
{
}
I've been searching online for a few hours but cannot figure out a way to properly sort the array alphabetically
Collections.sort()? or just simply doArrays.sort()