*  @param target - looking for where to insert 
 	 *  @return index i such that sarray[i] <= target, sarray[i] >= target
	 */
	private <T extends Comparable<? super T>> 
			int binSearch(ArrayList<T> sarray, T target)
	{
		int left = 0, right = sarray.size() - 1 ;
		int mid = 0;
		int loc = mid;

		if (right == -1) return -1; // nothing to insert in first slot
 
		// Check if what we are looking for is >= than largest element
		if (right >= 0  && sarray.get(right).compareTo(target) <= 0 )
			return right;
		// Check if what we are looking for is <= than smallest element
		if (sarray.get(left).compareTo(target)  >= 0 )
			return -1;

		// somewhere in the middle, binsearch for it
		while ((right - left) > 1 )
		{
			mid = (left + right)/2;
			T tmp = sarray.get(mid);
			int cvalue = tmp.compareTo(target);
			if (cvalue < 0)
			{
				left = mid;  // in (mid,right)
				loc = mid; 
			}
			else
			{
				right = mid;  // in (left,mid)
				loc = mid - 1;
			}
			if (cvalue == 0 ) return mid; // exact match, stop 
		}
		return loc;
	}