Insertion Sort List | Java | Easy and Simple Solution
\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val)
```\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n    public ListNode insertionSortList(ListNode head) {\n        ListNode dummy=new ListNode(-10000);\n        dummy.next=head;\n        ListNode prev=dummy;\n        ListNode curr=head;\n        \n        while(curr!=null){\n            if(curr.val>=prev.val){\n                prev=curr;\n                curr=curr.next;\n            }else{\n                ListNode temp=dummy;\n                while(temp.next.val<curr.val){\n                    temp=temp.next;\n                }\n                \n                prev.next=curr.next;\n                curr.next=temp.next;\n                temp.next=curr;\n                curr=prev.next;\n            }\n        }\n        \n        return dummy.next;\n    }\n}\n```
['Java']