public static void sortTwoSortedPartsInPlace(int[] a, int low1, int high1, int low2, int high2, int[] nn) {
		//nn[] is for pass reference and keep track of computation complexity
		int numCells1 = high1 - low1 + 1; 
		int numCells2 = high2 - low2 + 1;
		int numCells = numCells1 + numCells2;
		int[] ss = new int[numCells];
		
		int ssIndex = 0;
		int index1 = low1;
		int index2 = low2;
		
		while (ssIndex < numCells) {
			nn[0]++;
			if ( (index1 <= high1 && index2 <= high2 && a[index1] <= a[index2]) || (index1 <= high1 && index2 > high2)) {
				ss[ssIndex] = a[index1];
				index1++;
			} else {
				ss[ssIndex] = a[index2];
				index2++;
			}
			ssIndex ++;
		}
		
		for (int i = low1; i <= high1; i++) {
			nn[0]++;
			a[i] = ss[i-low1];
		}
		
		for (int i = low2; i <= high2; i++) {
			nn[0]++;
			a[i] = ss[i-low2+numCells1];
		}
		
	}