Sorting an array of arrays in Ruby

后端 未结 4 1923
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 00:07

I have an array of arrays like so:

irb(main):028:0> device_array
=> [[\"name1\", \"type1\", [\"A\", \"N\", \"N\"], [\"Attribute\", \"device_attribute\"], 9         


        
4条回答
  •  孤独总比滥情好
    2021-02-07 00:34

    I know the question has been answered, and I'm not going to address it now, but..

    Are you sure an array would be the best fit for that data? I'm talking about these data elements: ["name1", "type1", ["A", "N", "N"], ["Attribute", "device_attribute"], 9]

    Seems like a Struct or something might be more appropriate and manageable for this, and then you can have an array of Structs. Just an idea.

提交回复
热议问题