Raku 数组不会排序

con*_*con 5 rakudo raku

我正在尝试对字符串列表/数组进行排序:

> my @e = Q (list_regex_files json_file_to_ref write_2d_array_to_tex_tabular dir get_sample_ID density_scatterplot violin_plot multiline_plot ref_to_json_file execute venn barplot scatterplot_2d_color worksheet_to_hash group_bar workbook_to_hash read_table)
Run Code Online (Sandbox Code Playgroud)

使用https://docs.raku.org/type/Array#(List)_routine_sort我尝试

> say @e.sort
(list_regex_files json_file_to_ref write_2d_array_to_tex_tabular dir get_sample_ID density_scatterplot violin_plot multiline_plot ref_to_json_file execute venn barplot scatterplot_2d_color worksheet_to_hash group_bar workbook_to_hash read_table)
Run Code Online (Sandbox Code Playgroud)

say <list_regex_files json_file_to_ref write_2d_array_to_tex_tabular dir get_sample_ID density_scatterplot violin_plot multiline_plot ref_to_json_file execute venn barplot scatterplot_2d_color worksheet_to_hash group_bar workbook_to_hash read_table>.sort
Run Code Online (Sandbox Code Playgroud)

确实有效。但是,如何将数据保存到数组中然后对其进行排序?喜欢say @e.sort

p6s*_*eve 8

回应@Elizabeth 的评论,dd 是你的朋友......

> my @a1 = Q (a b c); dd @a1;   #Array @a1 = ["a b c"]
> my @a2 = <a b c>;   dd @a2;   #Array @a2 = ["a", "b", "c"]
Run Code Online (Sandbox Code Playgroud)

这是任何过往读者的文档https://docs.raku.org/language/quoting


Bra*_*ert 5

\n

Q是引用域特定子语言的基础。

\n

因此,它非常简单,它唯一做的就是原始引用。您甚至无法转义结束分隔符。

\n
say Q (a b c \\).raku\n# "a b c \\\\"\n
Run Code Online (Sandbox Code Playgroud)\n

您可以为该基本语言启用额外功能,例如启用:backslash. (:b是别名)

\n
say Q :backslash (a b c \\)).raku\n# "a b c )"\n
Run Code Online (Sandbox Code Playgroud)\n

您可能认为:words( :w) 或:quotewords( :ww) 功能已启用。

\n
say Q :words (a b c).raku\n# ("a", "b", "c")\n\nsay Q :quotewords (a b \'c d\' "e f").raku\n# ("a", "b", "c d", "e f")\n
Run Code Online (Sandbox Code Playgroud)\n
\n

其中一些功能非常有用,因此有其他方法可以编写它们。

\n

例如,:single( :q) 功能允许在结束定界符中使用反斜杠,但通常仅用单引号拼写\'\xc2\xa0\'

\n
\'a b c \\\' d\'    eqv    Q :single \'a b c \\\' d\'    eqv    Q:q \'a b c \\\' d\'\n
Run Code Online (Sandbox Code Playgroud)\n

q单引号还有另一个别名。

\n
\'a b c \\\' d\'    eqv    q \'a b c \\\' d\'\n
Run Code Online (Sandbox Code Playgroud)\n

还有一个捷径是拼写的<\xc2\xa0>

\n
<a b c>    eqv    Q :single :words (a b c)    eqv    Q:s:w (a b c)\n
Run Code Online (Sandbox Code Playgroud)\n

这是您认为自己正在使用的那个。

\n
\n

您可以启用或禁用更多功能。有关更全面的列表和示例,请参阅文档。

\n