相关疑难解决方法(0)

如何在ruby中对字母数字数组进行排序

我如何在ruby中以字母数字方式对数组数据进行排序?

假设我的数组是 a = [test_0_1, test_0_2, test_0_3, test_0_4, test_0_5, test_0_6, test_0_7, test_0_8, test_0_9, test_1_0, test_1_1, test_1_2, test_1_3, test_1_4, test_1_5, test_1_6, test_1_7, test_1_8, test_1_9, test_1_10, test_1_11, test_1_12, test_1_13, test_1_14, ...........test_1_121...............]

我希望我的输出是:

.
.
.
test_1_121
.
.
.
test_1_14
test_1_13
test_1_12
test_1_11
test_1_10
test_1_9
test_1_8
test_1_7
test_1_6
test_1_5
test_1_4
test_1_3
test_1_2
test_1_1
test_0_10
test_0_9
test_0_8
test_0_7
test_0_6
test_0_5
test_0_4
test_0_3
test_0_2
test_0_1
Run Code Online (Sandbox Code Playgroud)

ruby sorting alphanumeric natural-sort

3
推荐指数
3
解决办法
4092
查看次数

标签 统计

alphanumeric ×1

natural-sort ×1

ruby ×1

sorting ×1