Your sorting code in main() looks close, but as doomilator suggests, move it into the Sort() routine.
Then initialize j = i->NEXT and loop while j != NULL (otherwise you're needlessly comparing i to itself the first time, and never checking the last element in the list). Also, your comparison direction might be wrong at line 38. And you're swapping the first out-of-order element you find, but there might be a better one further on, so you have to check all of the j's before advancing i. Then double check that the right thing happens if you're swapping adjacent nodes (where before_j == i), though it might already be ok, just double-check. Finally, make sure you handle the degenerate cases where there are zero or one nodes in your list.
Good luck, and post back just your sort routine (if that's all that's broken) if you get stuck again. :)
raptr_dflo
Practically a Master Poster
605 posts since Aug 2010
Reputation Points: 76
Solved Threads: 83
Skill Endorsements: 1