So here's what I'm confused about. In my main method I have a a multitude of Faculty objects. In addition to having a FacultyList Arraylist.
ArrayList<Faculty> FacultyList = new ArrayList<>();
Faculty faculty1 = new Faculty(fName, "Bob", age, department, position);
Faculty faculty2 = new Faculty(fName, "Anderson", age, department, position);
Faculty faculty3 = new Faculty(fName, "Yvetal", age, department, position);
Faculty faculty4 = new Faculty(fName, "Thompson", age, department, position);
FacultyList.add(faculty1);
FacultyList.add(faculty2);
FacultyList.add(faculty3);
FacultyList.add(faculty4);
The situation now is that I need to either create a method or just put code in the main program to do an INSERTION SORT BASED ON THE LAST NAMES.
I had this before and it didn't change anything.
private static void insertionFaculty(ArrayList<Faculty> array)
{
Faculty temp;
for(int i = 1; i < array.size(); i++)
{
temp = array.get(i);
for(int j = i; j > 0; j--)
{
if(temp.getLastName().compareTo(array.get(j-1).getLastName()) < 0)
{
array.set(j, array.get(j - 1));
}
else
break;
array.set(j, temp);
}
}
}
Please help :)