private ListNode mergeSortList(ListNode head, int len) {
        if(len <= 1) {
            return head;
        }
        int leftLen = len/2;
        int rightLen = len - leftLen;

        //find middle pointer
        ListNode middle = head;
        for(int i=0; i<leftLen-1; i++) {
            middle = middle.next;
        }
        ListNode tmp = middle.next;
        middle.next = null;
        middle = tmp;

        //sort two part list
        ListNode leftHead = mergeSortList(head, leftLen);
        ListNode rightHead = mergeSortList(middle, rightLen);

        //merge two sorted lists
        ListNode dummy = new ListNode(0);
        ListNode p = dummy;
        while(leftHead!=null && rightHead!=null) {
            if(leftHead.val > rightHead.val) {
                p.next = rightHead;
                rightHead = rightHead.next;
            } else {
                p.next = leftHead;
                leftHead = leftHead.next;
            }
            p = p.next;
        }

        if(leftHead!=null) {
            p.next = leftHead;
        } else {
            p.next = rightHead;
        }

        return dummy.next;
    }