Java case insensitive localized ordering

坚强是说给别人听的谎言 提交于 2019-12-05 18:30:48

Below is the quote from the API.

It does not only depend on the strength but also other things. Enclose hyphen('-') between single quotes and you will get the desired output ''

The definitions of the rule elements is as follows:

  • Text-Argument: A text-argument is any sequence of characters, excluding special characters (that is, common whitespace characters [0009-000D, 0020] and rule syntax characters [0021-002F, 003A-0040, 005B-0060, 007B-007E]). If those characters are desired, you can put them in single quotes (e.g. ampersand => '&'). Note that unquoted white space characters are ignored; e.g. b c is treated as bc.

http://docs.oracle.com/javase/7/docs/api/java/text/RuleBasedCollator.html#compare(java.lang.String, java.lang.String)

There is no case sensitivity issue involved. The collator ignores spaces and hyphens so, since all strings start with “App”, the significant letters are “S”, “l”, and “B” in your example and the resulting order “B” “L” “S” is correct.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!