Desperate help needed with insertion sort code
Here is my insertion sort code for a doubly linked list that does not work. I cannot figure out why and I've been trying everything for the last 10 hours! Please Please help..
publicvoid insertionSort()
{
Node pointer=head;
while(pointer.next!=null)
{
Node insert=pointer.next;
if (insert.item.compareTo(pointer.item)>0)
{
pointer=pointer.next;
}
else
{
insert.prev.next=insert.next;
insert.next.prev=insert.prev;
if (head.item.compareTo(insert.item)>0)
{
insert.next=head;
insert.prev=null;
head.prev=insert;
head=insert;
}
Node current =head.next;
while (current.item.compareTo(insert.item)<0)
{
current=current.next;
}
insert.next=current;
insert.prev=current.prev;
current.prev.next=insert;
current.prev=insert;
}
}
}

