Insertion sort in doubly linked list HELP ME RHONDA!

This code causes my program to never stop running, I can't figure out why it will not sort the list.

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;

}

}

}

}

[1138 byte] By [javahockeya] at [2007-11-26 17:12:53]
# 1
How is that an insertion sort? On the list [0, 2, 1] it appears to just throw the 1 away.
YAT_Archivista at 2007-7-8 23:40:46 > top of Java-index,Other Topics,Algorithms...