private int[] merge(int[] first, int[] second) {
        int[] out = new int[first.length + second.length];
        int i = 0;
        int j = 0;
        int c = 0;
        while (i < first.length || j < second.length) {
            if (i == first.length) {
                for (int tmp = j; tmp < second.length; tmp++) {
                    out[c] = second[tmp];
                    c++;
                }
                break;
            }
            if (j == second.length) {
                for (int tmp = i; tmp < first.length; tmp++) {
                    out[c] = first[tmp];
                    c++;
                }
                break;
            }
            if (first[i] < second[j]) {
                out[c] = first[i];
                c++;
                i++;
            } else {
                out[c] = second[j];
                c++;
                i++;
            }
        }
        return out;
    }