使用数字对字符串进行排序的方式与一种语言不同.例如,英文数字在升序排序中位于字母之前.但是,在德语中,数字是在字母之后排序的.
我尝试使用Collator以下方法对字符串进行排序:
private Collator collator = Collator.getInstance(Locale.GERMANY);
collator.compare(str1, str2)
Run Code Online (Sandbox Code Playgroud)
但是上面的比较没有考虑字母后的数字规则.
有没有人知道为什么Java在我使用的时候没有考虑这个规则(字母后面的数字)RuleBasedCollator,如下所示:
private final String sortOrder = "< a, A < b, B < c, C < d, D < e, E < f, F < g, G < h, H < i, I < j, J < k, K < l, L < m, M < n, N < o, O < p, P < q, Q < r, R < s, S < t, T …Run Code Online (Sandbox Code Playgroud)