public int[] countSort(int[] tmpArray, int[] tmpRems){
		// the c[] is defined by the maximum number among tmpArray
		int[] count = new int[10];
		int[] sortArray = new int[tmpArray.length];
		// count
		for(int i=0; i<tmpRems.length; i++){
			count[tmpRems[i]]+=1;
		}
		// accumulate
		for(int i=0; i<count.length-1; i++){
			count[i+1] += count[i];
		}
		// put number in sortArray
		for(int i=tmpRems.length-1; i>=0; i--){
			sortArray[count[tmpRems[i]]-1] = tmpArray[i];
			count[tmpRems[i]]--;
		}
		return sortArray;
	}