Can Perl 6 sort or compare based on collations?

别说谁变了你拦得住时间么 提交于 2019-12-23 07:50:02

问题


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).


回答1:


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.



来源:https://stackoverflow.com/questions/44937854/can-perl-6-sort-or-compare-based-on-collations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!