private static <T extends Comparable<? super T>> void merge(ArrayList<T> list, ArrayList<T> temp, int start, int end){
		int middle = (start +end)/2 +1;
		int right = middle-1;
		int numberElements = end - start + 1;
		int tempPos = start;


		while(start <= right && middle<=end)
			if(list.get(start).compareTo(list.get(middle)) <= 0)
				temp.set(tempPos++, list.get(start++));
			else
				temp.set(tempPos++, list.get(middle++));

		while(start <= right)
			temp.set(tempPos++, list.get(start++));
		while(middle <= end)
			temp.set(tempPos++, list.get(middle++));

		for(int i = 0; i<numberElements; i++,end--){
			list.set(end, temp.get(end));
		}

	}