如何对 Java 中包含挪威字符的字符串进行排序?
How to Sort String with Norwegian Characters in Java?
æøå 是挪威字母表中最新的字母
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Æ Ø Å
List<String> words = Arrays.asList(
"A", "B", "Z", "Æ", "Ø", "Å" );
Locale la = new Locale("nor", "NOR");
Collator coll = Collator.getInstance(la);
coll.setStrength(Collator.PRIMARY);
Collections.sort(words, coll);
System.out.println(""+ words);
答案应该是
A, B, Z, Ø, Ø Å,
但我得到:
A、Å、Æ、B、Z、Ø
谁能建议如何获得上述输出?
语言环境错误。对于挪威语,语言是 'no',国家是 'NO'
List<String> words = Arrays.asList(
"Abba", "B", "BØ", "BÆ", "Z", "Æ", "Ø", "Å" );
Locale la = new Locale("no", "NO");
Collator coll = Collator.getInstance(la);
coll.setStrength(Collator.PRIMARY);
Collections.sort(words, coll);
System.out.println(""+ words);
正确输出:[Abba, B, BÆ, BØ, Z, Æ, Ø, Å]
æøå 是挪威字母表中最新的字母
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Æ Ø Å
List<String> words = Arrays.asList(
"A", "B", "Z", "Æ", "Ø", "Å" );
Locale la = new Locale("nor", "NOR");
Collator coll = Collator.getInstance(la);
coll.setStrength(Collator.PRIMARY);
Collections.sort(words, coll);
System.out.println(""+ words);
答案应该是
A, B, Z, Ø, Ø Å,
但我得到:
A、Å、Æ、B、Z、Ø
谁能建议如何获得上述输出?
语言环境错误。对于挪威语,语言是 'no',国家是 'NO'
List<String> words = Arrays.asList(
"Abba", "B", "BØ", "BÆ", "Z", "Æ", "Ø", "Å" );
Locale la = new Locale("no", "NO");
Collator coll = Collator.getInstance(la);
coll.setStrength(Collator.PRIMARY);
Collections.sort(words, coll);
System.out.println(""+ words);
正确输出:[Abba, B, BÆ, BØ, Z, Æ, Ø, Å]