Here's an object I'm working with in Ruby. It's a bunch of events sorted by date, but I want to nest the object one level deeper when there are two or more with the same event\_type next to each other in the object. 

```
@events = [ 
    { :id => 1, :event_type => "B", :created_at => "2013-09-30 14:44:24 UTC"},
    { :id => 2, :event_type => "A", :created_at => "2013-09-29 14:44:24 UTC"},
    { :id => 3, :event_type => "A", :created_at => "2013-09-28 14:44:24 UTC"},
    { :id => 4, :event_type => "C", :created_at => "2013-09-27 14:44:24 UTC"},
    { :id => 5, :event_type => "C", :created_at => "2013-09-26 14:44:24 UTC"},
    { :id => 6, :event_type => "A", :created_at => "2013-09-25 14:44:24 UTC"}
]

```

I'm looking to turn it into this:

```
@events = [
    { :id => 1, :event_type => "B", :created_at => "2013-09-30 14:44:24 UTC"},
    { :grouped_events => [
            { :id => 2, :event_type => "A", :created_at => "2013-09-29 14:44:24 UTC"},
                { :id => 3, :event_type => "A", :created_at => "2013-09-28 14:44:24 UTC"}
            ]
        },
    { :grouped_events => [
            { :id => 4, :event_type => "C", :created_at => "2013-09-27 14:44:24 UTC"},
            { :id => 5, :event_type => "C", :created_at => "2013-09-26 14:44:24 UTC"}
            ]
        },
    { :id => 6, :event_type => "A", :created_at => "2013-09-25 14:44:24 UTC"}
]

```

I need the overall object to keep the nested objects sorted by date, but if there are 2 or more events clustered together, I want them turned into an array, as seen by the sample output.
It seems like a simple problem, but I can't seem to figure it out.