/**
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
class Solution {
public:
/**
*
* @param head ListNode类 the head node
* @return ListNode类
*/
ListNode* sortInList(ListNode* head) {
// write code here
vector<int> result;
while(head){
result.push_back(head->val);
head = head->next;
}
sort(result.begin(), result.end()); ListNode* nohead = new ListNode(NULL);
for(int i = result.size()-1;i>=0;i--){
ListNode* p = new ListNode(result[i]);
p->next = nohead->next;
nohead->next = p;
}
return nohead->next;
}
};