且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用非西方字符对字符串进行排序

更新时间:2023-01-20 17:27:42

您应该将Collat​​or传递给sort方法:

You should pass a Collator to the sort method:

// sort according to default locale
Collections.sort(langs, Collator.getInstance());

默认排序顺序由字符串中的Unicode代码点定义,这不是正确的字母顺序任何语言。

The default sort order is defined by the Unicode codepoints in the string, and that's not the correct alphabetical order in any language.