【发布时间】:2020-05-28 12:49:16
【问题描述】:
这是一个非常简单的问题,但我无法解决。我有一个数组
@arr = qw(txt text anothertext 38.09 100.87 0.876)
如何按数字对数组中的数字和按字母顺序对字符串进行排序。所以输出看起来像:
@sorted_as = (anothertext text txt 100.87 38.09 0.876)
或者,
@sorted_des = (txt text anothertext 100.87 38.09 0.876)
抱歉,如果我重复了任何问题但找不到合适的答案。
【问题讨论】:
-
不应该
@sorted_as = (anothertext text txt 0.876 38.09 100.87)吗?我假设_as表示升序。
标签: perl sorting numeric alphabetical-sort