code: public static int compareToIgnoreCaseCarefulEquals(String S1, String S2) {
  		int diff=S1.compareToIgnoreCase(S2);
  		if(diff==0) diff=S1.compareTo(S2);
  		return diff;
  	}
docs: Compares two strings in a case insensitive manner.  However, if they are considered equals in the
  case-insensitive manner, the case sensitive comparison is done.