Rails, Ruby, how to sort an Array?

后端 未结 6 1487
忘了有多久
忘了有多久 2021-01-31 07:13

in my rails app I\'m creating an array like so:

@messages.each do |message|

  @list << {
    :id => message.id,
    :title => message.title,
    :ti         


        
6条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 07:44

    Yes, you can use group_by :

    http://api.rubyonrails.org/classes/Enumerable.html#method-i-group_by

提交回复
热议问题