News for hackers. Stuff that matters.
Re:Unicode sorting is hard and why browsers added special em... by twic on Monday June 28, 2021 @05:27AM (#27659664)
FWIW:

    List<String> sorted = Stream.of("Bären",
                                    "Käfer",
                                    "küssen",
                                    "Ähnlich",
                                    "Äpfel")
                                .sorted(Collator.getInstance(Locale.ROOT))
                                .collect(Collectors.toList());
    // [Ähnlich, Äpfel, Bären, Käfer, küssen]
In Java, String's default comparison is lexicographic over UTF-16 code units. Whilst this isn't precisely what you'd choose today, i do think it makes sense for the default comparison not to be locale-sensitive.

There are no comments on this comment yet.