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; } };