Rules / Types, classes & roles / basic

Collation Reference

Encapsulates instructions about how strings should be sorted

What it is #

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method set #

method set (

Sets if the different levels should be used in ascending or descending order, or if they are going to be ignored (when set to 0).

method primary #

method primary

Returns the state of the primary collation level.

method secondary #

method secondary

Returns the state of the secondary collation level.

method tertiary #

method tertiary

Returns the state of the tertiary collation level.

method quaternary #

method quaternary

Returns the state of the quaternary collation level.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

2 no-output · 1 rakupp-differs

class Collation { }

Not executed: the documentation states no expected output for this example.

Int :$primary    = 1,
Int :$secondary  = 1,
Int :$tertiary   = 1,
Int :$quaternary = 1)

Not executed: the documentation states no expected output for this example.

my $*COLLATION = Collation.new;
say 'a' coll 'z'; # OUTPUT: «Less␤»
$*COLLATION.set(:primary(-1));
say 'a' coll 'z'; # OUTPUT: «More␤»
Documentation
Less
More
Rakudo
Less
More
Raku++

Raku++ disagrees with both the documentation and Rakudo — a defect.