Skip to content

Instantly share code, notes, and snippets.

@neaf
Created March 18, 2009 15:45
Show Gist options
  • Save neaf/81204 to your computer and use it in GitHub Desktop.
Save neaf/81204 to your computer and use it in GitHub Desktop.
@all_items = []
@all_items.concat Message.all
@all_items.concat Writeboard.all
@items = {}
@all_items.each do |item|
t = item.created_at
date = Date.new(t.year, t.month, t.day)
if @items.has_key? date
@items[date] << item
else
@items[date] = [item]
end
end
@items.each_value do |items|
items.sort! { |x,y| y.created_at <=> x.created_at }
end
@items = @items.sort { |x,y| y <=> x }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment