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)
使用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)
但
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
确实有效。但是,如何将数据保存到数组中然后对其进行排序?喜欢say @e.sort?
回答
回应@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"]
这是任何过往读者的文档https://docs.raku.org/language/quoting