Sorting String with non-western characters

try

Collections.sort(langs, Collator.getInstance(new Locale("pl", "PL")));

it will produce

...
litewski
łotewski
...

see Collator API for details


You should pass a Collator to the sort method:

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

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


Have a look at java.text.Collator.newInstance(Locale). You need to supply the Polish locale in your case. Collators implement the Comparator interface, so you can use that in sort APIs and in sorted datastructures like TreeSet.