The RuleBasedCollator class is a concrete subclass of Collator that provides a simple, data-driven, table collator. With this class you can create a customized table-based Collator. RuleBasedCollator maps characters to sort keys.
RuleBasedCollator has the following restrictions for efficiency (other subclasses may be used for more complex languages) :
If a French secondary ordering is specified it applies to the whole collator object. All non-mentioned Unicode characters are at the end of the collation order. Private use characters are treated as identical. The private use area in Unicode is 0xE800-0xF8FF.
The collation table is composed of a list of collation rules, where each rule is of three forms:
The following demonstrates how to create your own collation rules:
Text-Argument: A text-argument is any sequence of characters, excluding special characters (that is, whitespace characters and the characters used in modifier, relation and reset). 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. Modifier: There is a single modifier which is used to specify that all accents (secondary differences) are backwards. '@' : Indicates that accents are sorted backwards, as in French. Relation: The relations are the following: