Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created March 10, 2025 11:10
Show Gist options
  • Save jskeet/41b9b6194b087f6194d6db18aaa2b9ec to your computer and use it in GitHub Desktop.
Save jskeet/41b9b6194b087f6194d6db18aaa2b9ec to your computer and use it in GitHub Desktop.
CzechCollationTest
import java.text.Collator;
import java.util.*;
public class CzechCollationTest {
public static void main(String[] args) {
Locale locale = new Locale("cs");
List<String> words = Arrays.asList(
"Účetnictví", "Udržitelná", "Uhlovodíky", "Vízová",
"Česká", "Řízení", "Škola", "Životní", "Chléb"
);
test(words, locale, null, "Without strength");
test(words, locale, Collator.PRIMARY, "With PRIMARY");
test(words, locale, Collator.SECONDARY, "With SECONDARY");
test(words, locale, Collator.TERTIARY, "With TERTIARY");
test(words, locale, Collator.IDENTICAL, "With IDENTICAL");
}
private static void test(List<String> list, Locale locale, Integer strength, String description) {
// Avoid mutating the existing list.
List<String> clone = new ArrayList<>(list);
Collator collator = Collator.getInstance(locale);
if (strength != null) {
collator.setStrength(strength);
}
clone.sort(collator);
System.out.println(description + ":" + String.join(", ", clone));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment