I have my program reading in the file(which contain first name and last names) from the user and printing it out. Now I need to write a method to sort the contents of the file by last name to call in the main. My question is where to begin. I started making my class for sortFile but am stuck on where to even begin.
package javaproject1;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
public class JavaProject1 {
public static void main(String[] args) throws FileNotFoundException
{
String check = "y";
do{
Scanner fileRead = new Scanner(System.in);
System.out.println("Enter the name of the file: ");
File myFile = new File(fileRead.next());
Scanner scanTwo = new Scanner(myFile);
while(scanTwo.hasNext())
{
String i = scanTwo.next();
String j = scanTwo.next();
String sortLast;
System.out.println(i + " " + j + " ");
}
System.out.println();
Scanner anw = new Scanner(System.in);
System.out.println("Add another? y/n ");
check = anw.next();
}while(check.equals("y"));
}
public File sortFile(String sortLast)
{
}
}