Everything compiles and everything runs correctly except my insertionSort(). When the user selects it in the app class it just list the last input the user made instead of showing the sorted list. HELP PLEASE! public void insertionSort(DoublyLinkedList dd) { DoublyLinkedList newLink = dd; DoublyLinkedList temp = first; if( extra == null ) //if empty list, { first = newLink;//newLink <--last first.next = null; first.previous = null; } else{ DoublyLinkedList previous=null; DoublyLinkedList next=first.next; DoublyLinkedList current=first; for(int i=0;temp.next!=null;i++){ if(Integer.parseInt(temp.dData.getId()) < Integer.parseInt(newLink.dData.getId())){ current=temp; previous=temp.previous; next=temp.next; } temp=temp.next;} newLink.previous=temp; newLink.next=temp.next; temp.next=newLink; next.previous=newLink; } Solution Try this code:- void insertionsort(node **d) { int n; node *cur; cur=*d; if(cur->next==Null) return; node *ptr, *tmp; cur=cur->next; while(cur!=NULL) { n=0; ptr=cur; tmp=cur->prev; cur=cur->next; while(tmp!=NULL && tmp->data->ptr->data) { n++; tmp=tmp->prev; } if(n) { ptr->prev->next=ptr->next; if(ptr->next!=NULL) ptr->next->prev=ptr->prev; if(temp==NULL) { tmp=*d; ptr->prev=NULL; ptr->next=tmp; ptr->next->prev=ptr; *d=ptr; } else { tmp=tmp->next; tmp->prev->next=ptr; ptr->prev=tmp->prev; tmp->prev=ptr; ptr->next=tmp; } } } } .