class Solution {
public:
    ListNode* sortList(ListNode* head) {
        multimap<int,ListNode*> mul;
        while(head){
            mul.insert(make_pair(head->val,head));
            head=head->next;
        }
        ListNode dummy(-1);
        head=&dummy;
        for(auto it=mul.begin();it!=mul.end();it++){
            head->next=it->second;
            head=head->next;
        }
        head->next=NULL;
        return dummy.next;
    }
};

 

posted on 2018-10-14 00:31  Sempron2800+  阅读(123)  评论(0编辑  收藏  举报