You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
379 B

package correct
func ListSort(l *NodeI) *NodeI {
head := l
if head == nil {
return nil
}
head.Next = ListSort(head.Next)
if head.Next != nil && head.Data > head.Next.Data {
head = move(head)
}
return head
}
func move(l *NodeI) *NodeI {
p := l
n := l.Next
ret := n
for n != nil && l.Data > n.Data {
p = n
n = n.Next
}
p.Next = l
l.Next = n
return ret
}