public void merge(int A[], int m, int B[], int n) {
        int[] list = new int[m + n];
        int indexa = 0;
        int indexb = 0;
        int index = 0;
        while (indexa < m && indexb < n) {
            if (A[indexa] < B[indexb])
                list[index++] = A[indexa++];
            else
                list[index++] = B[indexb++];
        }
        // a is over
        if (indexa == m) {
            while (indexb < n)
                list[index++] = B[indexb++];
            ;
        }
        if (indexb == n)
            while (indexa < m)
                list[index++] = A[indexa++];

        for (int i = 0; i < list.length; i++) {
            A[i] = list[i];
        }
    }