Skip to content

Instantly share code, notes, and snippets.

@toreriklinnerud
Created May 15, 2012 10:09
Show Gist options
  • Save toreriklinnerud/2700553 to your computer and use it in GitHub Desktop.
Save toreriklinnerud/2700553 to your computer and use it in GitHub Desktop.
log = [
{time: 201201, x: 2},
{time: 201201, y: 7},
{time: 201201, z: 2},
{time: 201202, a: 3},
{time: 201202, b: 4},
{time: 201202, c: 0}
]
@ryenus
Copy link

ryenus commented Aug 5, 2012

May I ask why the box keeps red for this?

@murtuzakz
Copy link

How about this :

log.group_by{|a| a[:time]}.map do |k,v|
  v.inject({}){|res,a| puts a; puts res; res.merge!(a)}
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment