Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Created October 11, 2013 19:50
Show Gist options
  • Save jakecraige/6940946 to your computer and use it in GitHub Desktop.
Save jakecraige/6940946 to your computer and use it in GitHub Desktop.
sortAndGroup = (objects)->
sorted = _.sortBy objects, (object)->
object.date
.reverse()
grouped = _.groupBy sorted, (object)->
object.date
_.inject grouped, (results, val, ind)->
results.push { date: { value: ind, activities: val} }
results
, []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment