public ListNode sortList(ListNode head) {
        int length = 0;
        ListNode node = head;
        while(node != null){
            length++;
            node = node.next;
        }
        if(length > 1){
            ListNode left = head;
            ListNode right;
            node = head;
            for (int i = 0 ; i< length /2 -1; i++){
                node = node.next;
            }
            right = node.next;
            node.next  = null;
            left = sortList(left);
            right = sortList(right);
            head = merge(left,right);
            return head;
        }
        return head;
    }