Decorate-sort-undecorate idiom
It is somewhat rare to do, or even need to do an explicit schwartzian transform in Raku. You can pass a transform function to the sort operator, and it will use it to do its comparisons. As long as the transform is arity one (only takes one value,) the sort will automatically perform a schwartzian transform transparently, behind the scenes.
Here the transform .chars
is arity one, so a schwartzian transform is performed automatically by the compiler.
( dd
is the built in "data-dumper" function; a verbose and explicit representation of an objects contents.)
More complicated transforms may require an explicit schwartzian transform routine. An example of where an explicit transform is desirable is the schwartzian()
routine in the Raku entry for the P-value_correction task.
Last updated