结果类似导向:
b = []
for i in 0...data.size
b << data.type_name
end
b >>>>>> ["消耗","消耗",......"素材","素材",......"合成","合成",......"武器","武器",......]
作者: 灯笼菜刀王 时间: 2023-6-1 20:24
b = []
a.each{|i| b += data.find_all{|j| j.type_name == i}}
data = b 作者: 765111039 时间: 2023-6-1 22:06
额 楼主你自己不是写出答案了吗,是我的话我会这样写吧,功力较低
b = []
b1=[]
b2=[]
b3=[]
for i in 0...data.size
b.push(i) if data[i].type_name == "消耗"
b1.push(i) if data[i].type_name == "素材"
b2.push(i) if data[i].type_name == "合成"
b3.push(i) if data[i].type_name == "武器"
end
b.push(b1)
b.push(b2)
b.push(b3)
data = b