Documentation for method
collate assembled from the following types:
collate method sorts taking into account Unicode grapheme characteristics; that is, sorting more or less as one would expect instead of using the order in which their codepoints appear.
collate will behave this way if the object it is applied to is
say ('a', 'Z').sort; # (Z a)say ('a', 'Z').collate; # (a Z)say <ä a o ö>.collate; # (a ä o ö)my = 'aa' => 'value', 'Za' => 'second';say .collate; # (aa => value Za => second);
This method is affected by the
$*COLLATION variable, which configures the four collation levels. While Primary, Secondary and Tertiary mean different things for different scripts, for the Latin script used in English they mostly correspond with Primary being Alphabetic, Secondary being Diacritics and Tertiary being Case.
In the example below you can see how when we disable tertiary collation which in Latin script generally is for case, and also disable quaternary which breaks any ties by checking the codepoint values of the strings, we get Same back for A and a:
.set(:quaternary(False), :tertiary(False));say 'a' coll 'A'; # OUTPUT: «Same␤»say ('a','A').collate == ('A','a').collate; # OUTPUT: «True␤»
The variable affects the
coll operator as shown as well as this method.
Supply it is called on. Once that
done, all of the values that it emitted will be sorted taking into account Unicode grapheme characteristics. A new
Supply is returned with the sorted values emitted. See Any.collate for more details on the collated sort.
my = Supply.from-list(<ä a o ö>);my = .collate();.tap(); # OUTPUT: «a␤ä␤o␤ö␤»