public static ListNode sortList(ListNode head) {//passed after consulting
        if (head == null || head.next == null) {
            return head;
        }
        ListNode s1 = head;
        ListNode s2 = head;
        while (s2.next != null && s2.next.next != null) {
            s1 = s1.next;
            s2 = s2.next.next;
        }
        ListNode head1 = head;
        ListNode head2 = s1.next;
        s1.next = null;
        head1 = sortList(head1);
        head2 = sortList(head2);
        return mergeTwoLists(head1, head2);
    }