public static int compareIgnoreCase(String string1, String string2) {
        if (string1 == null || string2 == null) {
            return 0;
        }
        int len1 = string1.length();
        int len2 = string2.length();
        for (int i = 0; i < len1 && i < len2; i ++) {
            char char1 = string1.charAt(i);
            char char2 = string2.charAt(i);
            if (char1 != char2) {
                char1 = Character.toUpperCase(char1);
                char2 = Character.toUpperCase(char2);
                if (char1 != char2) {
                    // as stated by the javadoc,
                    // Note that
                    // Character.isUpperCase(Character.toUpperCase(codePoint))
                    // does not always return true                    
                    // that's why use double conversion
                    char1 = Character.toLowerCase(char1);
                    char2 = Character.toLowerCase(char2);
                    if (char1 != char2) {
                        return char1 - char2;
                    }
                }
            }
        }
        return len1 - len2;
    }