java - Incorrect evaluation of String using Collator -
i'm trying use collator fast way sort 2 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 result got 1, means "test sortowania" > "testowanie sortowania jeszcze raz".
however think should opposite, space character should less 'o'.
am missing something?
Comments
Post a Comment