I'm trying to use Collator as fast way to sort two string using following code:
public static void main(String[] args) {
String str1 = "test Sortowania";
String str2 = "Testowanie sortowania jeszcze raz";
System.out.println(compare(str1,str2));
}
public static int compare(String s0, String s1) {
boolean ignoreCase = true;
Collator c = Collator.getInstance(new Locale("pl", "PL"));
return (ignoreCase ? c.compare(s0.toUpperCase(new Locale("pl", "PL")),
s1.toUpperCase(new Locale("pl", "PL"))) : c.compare(s0, s1));
}
As a result I got 1, that means "test Sortowania" > "Testowanie sortowania jeszcze raz".
However I think it should be opposite, as space character should be less than 'O'.
Am I missing something?