Forum: Ruby on Rails Collection grouping/sorting question

Posted by eggie5 (Guest)
on 2010-02-08 13:02
(Received via mailing list)
@coll= [{:period=>{:people=>[#], :date=>Sun, 08 Feb 2009}},
{:period=>{:people=>[#, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #,
#, #], :date=>Sun, 15 Feb 2009}}, {:period=>{:people=>[#, #, #, #, #,
#, #, #, #, #, #, #, #, #], :date=>Sun, 22 Feb 2009}},
{:period=>{:people=>[#, #], :date=>Sat, 28 Feb 2009}},
{:period=>{:people=>[#, #, #, #, #, #, #], :date=>Sun, 01 Mar 2009}},
{:period=>{:people=>[#, #, #], :date=>Sun, 08 Mar 2009}},
{:period=>{:people=>[#, #, #, #, #, #], :date=>Sun, 15 Mar 2009}},
{:period=>{:people=>[#], :date=>Wed, 18 Mar 2009}},
{:period=>{:people=>[#, #, #], :date=>Sun, 22 Mar 2009}},
{:period=>{:people=>[#], :date=>Sun, 29 Mar 2009}},
{:period=>{:people=>[#, #, #, #, #, #, #, #, #, #], :date=>Sun, 05 Apr
2009}}, {:period=>{:people=>[#], :date=>Sun, 12 Apr 2009}},
{:period=>{:people=>[#, #, #, #, #, #, #, #, #, #, #], :date=>Sun, 19
Apr 2009}}, {:period=>{:people=>[#, #, #, #, #, #, #, #,
#], :date=>Sun, 26 Apr 2009}}, {:period=>{:people=>[#, #, #, #, #, #,
#, #, #, #, #, #, #, #, #, #], :date=>Sun, 03 May 2009}}]


I have the above collection of hashes. Each hash has a date and a
collection of people objects. I want to group this collection by month
according to the date attribute. What's a good way to do this? I can't
think...
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.