我在.each_slice(2)
处有此代码,然后我想按字母顺序sort
,但是仅在之后添加排序也不起作用to_a.sort
也不起作用:
.form-group__container
.form-group__row
- Algorithm.where(filterable: 'true').each_slice(2).sort do |algorithms|
.form-group__col
- algorithms.each do |algorithm|
有人可以告诉我如何在红宝石上做它吗?
在@dimanyc的帮助下,我的问题的解决方案如下:
- Algorithm.where(filterable: 'true').sort_by(&:name).each_slice(2) do |algorithms|