如何按红宝石字母顺序排序

问题描述 投票:-1回答:1

我在.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|

有人可以告诉我如何在红宝石上做它吗?

ruby-on-rails ruby haml
1个回答
0
投票

在@dimanyc的帮助下,我的问题的解决方案如下:

- Algorithm.where(filterable: 'true').sort_by(&:name).each_slice(2) do |algorithms|
© www.soinside.com 2019 - 2024. All rights reserved.