Hi,
I've created a Person Class with a comparable interface. And i've created an ArrayList People with varaibles from the person class in - First_name, Surname, Month(Birthday), Day(Birthday).
Now i need to use selection sort to sort my arraylist into birthday order. In the Person Class i have a method which gives each person a different number for every possible birthday there is.
I have created a selction sort but dont know how to call the birthday from my array list and then to sort it.
This is my code for the selection sort so far:
import java.util.ArrayList.*;
public class Main
{
public static void selectionSort(Comparable[] people)
{
for (int k = people.length-1; k>0; k --)
{
Comparable tmp;
int Large = 0;
for (int j=1; j<= k; j++)
{
if (people[j].compareTo(people[k]) <0)
{
Large = j;
}
tmp = people[Large];
people[Large] = people[k];
people[k] = tmp;
}
}
}
}
this method compiles but i need to sort the birthday and dont know how. Also i need to output the whole array in birthday order.
Any help would be very greatful.
Thanks
Dave