Hello,
I am trying to make a linked list program that will take two parameters and sort first by age (least to greatest), then by name (alphabetically). The lists sorts fine until I enter an age greater than some values but less than others. At that point it does not sort correctly anymore.
For example, I entered:
"Three - 20, Four - 20, John - 68, Doe - 50"
and it sorted and displayed:
"20 Four", 20 Three, 68 John, 50 Doe."
Through trial and error, I am fairly certain that the problem lies in the "greater than" operator function, but I am not sure what exactly is failing.
It seems to me that you're inserting your new node after the first greater than it, not before.
I think that if you changed the condition on line 50 to > *p_node->next, it should be fine.