I want to group my JavaScript array of objects by two attributes of the object contained within.
I have tried underscores groupBy and it seems to accept only one attribute at a time.
_.groupBy([{'event_date':'2013-10-11', 'event_title':'Event 2'}, {'event_date':'2013-01-11', 'event_title':'Event 1'}], 'event_title')
My question is... is there a way to group an array of objects by two of its attributes.
Like in Ruby
[#<struct Event event_date=2013-10-11, event_title=Event 2>, #<struct Event event_date=2013-01-11, event_title=Event 1>].group_by{|p| p.event_date and p.event_title}