### Question:
HumanComparator implements Comparator< String > { public int compare( String str1, String str2 ) { if( StringUtils.equals( str1, str2 ) ) { return 0; } else if ( str1 == null ) { return -1; } else if ( str2 == null ) { return 1; } char[] s1 = str1.toCharArray(); char[] s2 = str2.toCharArray(); int len1 = s1.length; int len2 = s2.length; int idx = 0; int caseComparison = 0; while ( idx < len1 && idx < len2 ) { char c1 = s1[idx]; char c2 = s2[idx++]; char lc1 = Character.toLowerCase( c1 ); char lc2 = Character.toLowerCase( c2 ); if( caseComparison == 0 && c1 != c2 && lc1 == lc2 ) { if( Character.isLowerCase( c1 ) ) caseComparison = 1; else if( Character.isLowerCase( c2 ) ) caseComparison = -1; } c1 = lc1; c2 = lc2; if( c1 != c2 || c1 == '0' ) { CharType type1 = mapCharTypes( c1 ); CharType type2 = mapCharTypes( c2 ); int result = compareCharTypes( type1, type2 ); if( result != 0 ) { return result; } if( type1 != CharType.TYPE_DIGIT ) { Character ch1 = Character.valueOf( c1 ); Character ch2 = Character.valueOf( c2 ); return ch1.compareTo( ch2 ); } assert( type1 == CharType.TYPE_DIGIT && type2 == CharType.TYPE_DIGIT ); result = compareDigits( s1, s2, idx - 1 ); if( result != 0 ) { return result; } while ( idx < len1 && idx < len2 && Character.isDigit( s1[idx] ) ) { idx++; } } } if( len1 == len2 ) { return caseComparison; } return len1 - len2; } HumanComparator();  HumanComparator( CharType[] sortOrder ); static Comparator<String> getInstance(); int compare( String str1, String str2 ); CharType[] getSortOrder(); void setSortOrder( CharType[] sortOrder ); static final Comparator<String> DEFAULT_HUMAN_COMPARATOR; }### Answer:
@Test public void testCompare() { Comparator<String> comparator = new HumanComparator(); Assertions.assertTrue( comparator.compare( "abcd001", "ABCD001" ) > 0 ); Assertions.assertTrue( comparator.compare( "abcd001a", "ABCD001z" ) < 0 ); Assertions.assertTrue( comparator.compare( "abc8", "abcd1" ) < 0 ); Assertions.assertTrue( comparator.compare( "abc 8", "abc1" ) < 0 ); Assertions.assertTrue( comparator.compare( "abc 8", "abc 1" ) < 0 ); Assertions.assertTrue( comparator.compare( "abdc001", "ABCD001" ) > 0 ); Assertions.assertTrue( comparator.compare( "ab cd001", "ABDC001" ) < 0 ); Assertions.assertTrue( comparator.compare( "10", "01" ) > 0 ); Assertions.assertTrue( comparator.compare( "10", "00000001" ) > 0 ); Assertions.assertTrue( comparator.compare( "01", "00000001" ) < 0 ); }