我有Array
,其中包含混合数据。
就像
["AB_1020", "AB_950", "AB_50", "1000", "570"]
输出应为
AB_50, AB_950, AB_1020, 570, 1000
答案 0 :(得分:2)
["AB_1020", "AB_950", "AB_50", "1000", "570"].sort_by do |k|
i, w = k.split('_').rotate
[w.to_s, -i.to_i]
end.reverse
#⇒ ["AB_50", "AB_950", "AB_1020", "570", "1000"]
答案 1 :(得分:2)
你可以做这样的事情
#⇒ ["AB_50", "AB_950", "AB_1020", "570", "1000"]
ouptut
<button onclick=this.form.submit();>Pay Now</button>