Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Perl 6 sort or compare based on collations?

Tags:

collation

raku

The cmp operator works on code numbers, or at least that's what I think it does because the docs aren't explicit on that and don't mention any localization stuff.

Can I make it sort by other collations? I know I tell sort how to compare, but I figure it must be in there already (somewhere).

like image 589
brian d foy Avatar asked Jul 06 '17 00:07

brian d foy


1 Answers

Collation is available as an experimental feature:

my @list = <a ö ä Ä o ø>;
say @list.sort;                     # (a o Ä ä ö ø)

use experimental :collation;
say @list.collate;                  # (a ä Ä o ö ø)
$*COLLATION.set(:tertiary(False));
say @list.collate;                  # (a Ä ä o ö ø)

Please give feedback on this feature to help it move out of the "experimental" state and be included in v6.d.

like image 107
moritz Avatar answered Jan 02 '23 18:01

moritz