Using insertion sort
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n    ListNode* insertionSortList(ListNode* head) {\n        if(head==NULL || head->next==NULL)\n            return head;\n        ListNode* dummy=new ListNode(0);\n        ListNode* cur=head;\n\n        while(cur!=NULL){\n            ListNode* pre=dummy;\n            ListNode* next=cur->next;\n\n            while(pre->next!=NULL && pre->next->val<cur->val)\n                pre=pre->next;\n            \n            cur->next=pre->next;\n            pre->next=cur;\n            cur=next;\n        }\n\n        return dummy->next;\n    }\n};\n```
['C++']