while hand-writing the code,I meet with some trivial problems,which greatly worries me.
1.since it's a singly list, if we don't modify the list, we have to change the usual sort algorithm a bit , such as ,put the current max at the current end of the list rather than the min to the very front
2.how to avoid revisit sorted part?
first I intend to record a globalmax as a mark so that whenever a globalmax is met, it means that the following part has been sorted , but it can't handle
repeated data,such as 5 2 5 1 1, after one 5 is pushed till the end of the list, we can see that value field is changed to 2 5 1 1 5, and the next first 5 is located at pos with index 1 (start from 0),so it recognize 2 5 1 1 5 as sorted,which is wrong;
so an optimized solution is to store the length of the list when finding the max element for the first time, so iteration list can be decremented by 1 each time
3. NULL pointer and one element case ,which is usual edge handling