ListNode* sortInList(ListNode* head) {
ListNode * curNode = head;
ListNode * temp;
while(curNode->next){
temp=curNode->next;
while(temp){
if(temp->val < curNode->val){
int tempval=temp->val;
temp->val=curNode->val;
curNode->val=tempval;
}
temp=temp->next;
}
curNode=curNode->next;
}
return head;
}


京公网安备 11010502036488号