1) Instead of trying to think of an algorithm yourself, use the ones that are known. Which algorithm are you trying to implement? Bubble sort? Quicksort? Insertion Sort? Heap Sort?

2) Did you use a debugger to find where the problem is? This is just a matter of using a debugger.

3) The easiest way to solve your problem is to use a technique used by programmers who use the MFC CList, which does not have a "sort" function -- copy the linked list elements to an array, sort the array, and then recreate the list with the sorted elements of the array. Since the elements in the array are sorted, it is simple just to keep adding to the tail of the new linked list.

Regards,

Paul McKenzie