//链表 排序
public static LinkedLISTtask44(LinkedLIST head){
LinkedLIST dummy =new LinkedLIST(-1,null);
dummy.next = head;
LinkedLIST pre = dummy;
LinkedLIST curr = head;
LinkedLIST wait =null;
while (curr !=null && curr.next !=null){
wait = curr.next;
if(wait.value
while (pre.next !=null && wait.value >pre.next.value){
pre = pre.next;
}
LinkedLIST temp1 = wait.next;
LinkedLIST temp2 = pre.next;
pre.next = wait;
wait.next = temp2;
curr.next = temp1;
pre = dummy;
}else{
curr = curr.next;
}
}
return dummy.next;
}
网友评论