(1) 利用额外空间
class Solution {
public:
ListNode* sortList(ListNode* head)
{
vector<int> temp;
ListNode* p=head;
while (p!=NULL)
{
temp.push_back(p->val);
p=p->next;
}
int len=temp.size();
sort(temp.begin(),temp.begin()+len);
ListNode* q=head;
int i=0;
while(q!=NULL)
{
q->val=temp[i++];
q=q->next
}
return head;
}
};