C++
\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\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 == nullptr ){\n            return nullptr ;\n        }\n       vector<ListNode*>nodes;\n        nodes.push_back(head);\n        ListNode*temp = head->next ;\n        while(temp != nullptr ){\n            nodes.push_back(temp);\n            for(int i = nodes.size()-1 ; i > 0 ; i -- ){\n                if( nodes[i]->val < nodes[i-1]->val ){\n                     swap(nodes[i-1]->val , nodes[i]->val);    \n                }\n                else{\n                    break;\n                }\n            }\n            temp = temp->next;\n        }\n       return head ;\n    }\n};\n```
[]