
Collator::sort를 사용하여 한글과 영문이 함께 정렬되도록 하려면, Collator 인스턴스를 생성할 때 locale을 설정해야 합니다. 예를 들어, 한국어로 정렬하려면 다음과 같이 설정할 수 있습니다.
#hostingforum.kr
java
Collator collator = Collator.getInstance(Locale.KOREA);
collator의 locale을 설정하지 않으면, 기본적으로 영문으로 정렬됩니다.
Collator::sort를 사용하여 특정 문자열을 무시하고 싶을 때는, collator의 ignorableChars() 메서드를 사용할 수 있습니다. 예를 들어, 특정 문자열을 무시하고 싶을 때 다음과 같이 설정할 수 있습니다.
#hostingforum.kr
java
collator.setIgnoreNonIgnorables(true);
collator.setIgnorableChars("특정문자");
collator.setIgnoreNonIgnorables(true) 메서드를 사용하여 collator가 무시할 문자를 무시하지 않는 경우의 문자도 무시하도록 설정할 수 있습니다.
collator.setIgnorableChars() 메서드를 사용하여 특정 문자열을 무시하도록 설정할 수 있습니다. 이 메서드는 collator가 무시할 문자를 배열로 받습니다. 예를 들어, 다음과 같이 설정할 수 있습니다.
#hostingforum.kr
java
collator.setIgnorableChars(new String[]{"특정문자1", "특정문자2"});
2025-05-27 07:45