I did this sort function in C++ for Linked List
void sort()
{
node* ctr;
node* innerctr;
info temp;
node* max;
ctr = start;
while(ctr!=NULL)
{
innerctr=ctr->next;
max=ctr;
while(innerctr!=NULL)
{
if((innerctr->student.name) > (max->student.name))
{
max=innerctr;
}
innerctr=innerctr->next;
}
//swapping...
ctr=ctr->next;
}
}
I need to do something similar in Java and I want to use the LinkedList ready class but I am a bit confused because there are no pointers.
With as few modifications as possible, nearly the same thing in Java:
And here is the improved version, with Type “Student” as parameter for the Node:
The problem with the unspecified ‘start’ is inherited from you.