I\'m writing a simple file for one of my classes that is a simple linked list activity and I need to sort a linked list.
This is my source code so far:
/
I figured it out after some stack traces with a friend. Heres the fixed code:
struct node *sort_list(struct node *head) {
struct node *tmpPtr = head;
struct node *tmpNxt = head->next;
int tmp;
while(tmpNxt != NULL){
while(tmpNxt != tmpPtr){
if(tmpNxt->value < tmpPtr->value){
tmp = tmpPtr->value;
tmpPtr->value = tmpNxt->value;
tmpNxt->value = tmp;
}
tmpPtr = tmpPtr->next;
}
tmpPtr = head;
tmpNxt = tmpNxt->next;
}
return tmpPtr ; // Place holder
}