The code I have isn't right, and I know it. However, I've spent a few hours on this and don't know what else to do. I know the basics of insertion sort, but linked lists confuse me.
In other words, I know the theory. How do I actually apply it? This is the code for insertion sort that I have (I'm using a dummy node for head).
Code:
for (cursor = head->rlink(); cursor != NULL; cursor = cursor->rlink()) {
cursor2 = cursor;
while (cursor2->rlink() != NULL && cursor2->rlink()->value > cursor->value) {
cursor2 = cursor2->rlink(); // maybe llink?
}
Node *temp;
temp = cursor;
cursor2->set_llink(cursor->llink());a
temp->set_llink(cursor2->rlink());
}