Reputation: 5957
æøå is the latest letters in the norwegian alphabet
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);
The answer should be
A, B, Z, Æ, Ø Å,
But i am getting:
A, Å, Æ, B, Z, Ø
Can anyone suggest how to get above output?
Upvotes: 2
Views: 1236
Reputation: 5957
The locale was wrong. For norwegian, language is 'no' and Country is '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);
Correct Output: [Abba, B, BÆ, BØ, Z, Æ, Ø, Å]
Upvotes: 5