hi,
i've now created a sorting algorithm which i am happy with. But i cant get it to sort between to Person Objects.
Heres the code:
the variable a is the array, i have created an array called people but when i input people instead of a it doesnt call my array people - it just creates the variable people.
This is really annoying me!!
Any help would be great, thanks
Dave
i've now created a sorting algorithm which i am happy with. But i cant get it to sort between to Person Objects.
Heres the code:
Code:
public class main1
{
public static void insertionSort(Comparable [] a)
{
int j;
for (int i = 0; i<a.length; i++)
{
Comparable Person = a[i];
for ( j = i; j>0; j--);
{
if (a[j-1].compareTo (a) <0)
{
break;
}
else
{
a[j] = a[j-1];
}
}
a[j] = Person;
}
}
}
This is really annoying me!!
Any help would be great, thanks
Dave
Comment