publicListNodeinsertionSortList(ListNode head) {if (head ==null) {returnnull; }// this is the new head, don't need to dummy.next = head;ListNode dummy =newListNode(-1);// consider first half is sorted// pick next one and insert it in therewhile (head !=null) {ListNode node = dummy;// node before the insertion pointwhile (node.next!=null&&node.next.val<head.val) { node =node.next; }ListNode tmp =head.next;head.next=node.next;node.next= head; head = tmp; }returndummy.next;}