I have to sort a string of names in descending order in bubble sort. I tried but it is not working. This is what I have so far:
public static void bubbleSort(Student[] array)
{
for(int i=(array.length); i>0; i--)
{
for(int j=1; j<(array.length-i); j++)
{
if( array[j].getName().compareTo(array[j+1].getName())<0)
{
Student Temp = array[j];
array[j] = array[j+1];
array[j+1] = Temp;
}
}
}
}
Try this logic