private int[] merge(int[] left, int[] right) {
        int leftLen = left.length, rightLen = right.length;
        int leftPos = 0, rightPos = 0;
        int[] result = new int[leftLen + rightLen];
        int resultPos = 0;
        while(leftPos < leftLen && rightPos < rightLen) {
            if(left[leftPos] < right[rightPos]) {
                result[resultPos++] = left[leftPos++];
            }
            else {
                result[resultPos++] = right[rightPos++];
            }
        }

        if(leftPos < leftLen) {
            int count = leftLen - leftPos;
            System.arraycopy(left, leftPos, result, resultPos, count );
        }

        if(rightPos < rightLen) {
            int count = rightLen - rightPos;
            System.arraycopy(right, rightPos, result, resultPos, count );
        }

        return result;

    }