Posted By

sionnnn on 05/11/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


rails sort_by and group_by


 / Published in: Ruby
 

  1. @posts.sort_by(&:date).each do |post|
  2. puts post
  3. end
  4.  
  5. @tasks = {}
  6. TaskList.find(:all).group_by(&:type) do |type, subtasks|
  7. @tasks[type] = subtasks.group_by(&:name)
  8. end

Report this snippet  

You need to login to post a comment.