/**
 * 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> s;
        while(head) {
            s.push_back(head->val);
            head = head->next;
        }
        sort(s.begin(), s.end(), greater<int>());
        auto p = new ListNode(-1);
        for(int i = 0; i < s.size(); i++) {
            auto q = new ListNode(s[i]);
            q->next = p->next;
            p->next = q;
        }
        return p->next;
    }
};