/** * @(#)testArrayList.java * * * @author Michael Cecconet * @version 1.00 2007/3/5 */ import java.util.Arrays; import java.util.ArrayList; import java.lang.String; public class AlphabeticalSort { static ArrayList studentTracker = new ArrayList(); public static void alphaSort(){ char[] name1, name2; String nam1,nam2; student placeHolder; student[] tempArray = new student[studentTracker.size()]; for(int i=0;i= 0){// Check For the same last name, if true compares first names. //System.out.println(tempArray[i].showLastName()+", "+tempArray[i].showFirstName()+" has the same last name as "+tempArray[i+1].showLastName()+", "+tempArray[i+1].showFirstName() ); nam1= tempArray[i].showFirstName().toLowerCase(); nam2= tempArray[i+1].showFirstName().toLowerCase(); name1 = nam1.toCharArray(); name2 = nam2.toCharArray(); } for (int j=0;j <= name1.length;j++){ if (name1[j] > name2[j]){ //System.out.println(tempArray[i].showLastName()+", "+tempArray[i].showFirstName()+" goes behind "+tempArray[i+1].showLastName()+", "+tempArray[i+1].showFirstName() ); placeHolder=tempArray[i]; tempArray[i]=tempArray[i+1]; tempArray[i+1]=placeHolder; break; } else { if (name1[j] < name2[j]){ //System.out.println(tempArray[i].showLastName()+", "+tempArray[i].showFirstName()+" is in proper position between "+tempArray[i+1].showLastName()+", "+tempArray[i+1].showFirstName() ); break; } } } } } for (int k=0;k