public void merge (int[] array, int a, int b, int x, int y, int w) {

        int i = a, j = x;
        int temp = 0;

        while (i<=b && j <= y) {

            if (array[i] < array[j]) {
                temp = array[i];
                array[i] = array[w];
                array[w] = temp;         
                i++;
            } else {
                temp = array[j];
                array[j] = array[w];
                array[w] = temp;         
                j++;
            }
            w++;

            while (i<=b) {
                temp = array[i];
                array[i] = array[w];
                array[w] = temp;         
                i++;
                w++;
            }

            while (j<=y) {
                temp = array[j];
                array[j] = array[w];
                array[w] = temp;         
                j++;
                w++;
            }
        }
    }