且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Java进行语言排序(德语)

更新时间:2023-12-04 19:13:22

您可以检查/调试源代码以查看为什么没有任何变化:

You can check/debug the source code to see why nothing changes:

Collator.getInstance(Locale.GERMANY);

调用以下代码:

public static synchronized
Collator getInstance(Locale desiredLocale)
{
    // Snipping some code here
    String colString = "";
    try {
        ResourceBundle resource = LocaleData.getCollationData(desiredLocale);

        colString = resource.getString("Rule");
    } catch (MissingResourceException e) {
        // Use default values
    }
    try
    {
        result = new RuleBasedCollator( CollationRules.DEFAULTRULES +
                                        colString,
                                        CANONICAL_DECOMPOSITION );
    }
// Snipping some more code here

在这里你可以看到默认值 code> Collat​​ionRules.DEFAULTRULES / code>)。

Over here you can see that the specific rules (colString which is empty in your case anyway) are placed after the defaults (CollationRules.DEFAULTRULES).

并且您已经发现默认值首先放置数字:

And as you have discovered that defaults have the numerics placed first:

  // NUMERICS

    + "<0<1<2<3<4<5<6<7<8<9"
    + "<\u00bc<\u00bd<\u00be"   // 1/4,1/2,3/4 fractions

    // NON-IGNORABLES
    + "<a,A"
    + "<b,B"
    + "<c,C"
    + "<d,D"