public static int[] merge(int[] a, int[] b){
		int[] result = new int[a.length + b.length];
		int aIndex = 0, bIndex = 0, resIndex = 0;

		while(aIndex < a.length && bIndex < b.length){
			if(a[aIndex] == b[bIndex]){
				result[resIndex++] = a[aIndex++];
				result[resIndex++] = b[bIndex++];
			}
			if(a[aIndex] < b[bIndex]){
				result[resIndex] = a[aIndex];
				aIndex++;
				resIndex++;
			}
			if(a[aIndex] > b[bIndex]){
				result[resIndex] = b[bIndex];
				bIndex++;
				resIndex++;
			}
		}

		while(aIndex < a.length){
			result[resIndex++] = a[aIndex++];
		}

		while(bIndex < b.length){
			result[resIndex++] = b[bIndex++];
		}

		return result;
	}