code: function groupByKey (arr, grouper) {
    var groups = {}
  
    arr.forEach(function (obj) {
      var key = grouper(obj)
      if (key in groups) groups[key].push(obj)
      else groups[key] = [obj]
    })
  
    return groups
  }
docs: Group an array (arr) of objects using the given grouping function (grouper).
  
  Only requirement is that the grouping function - given an object - returns a
  key that should be used to group that object.
  
  Returns an object where each key represents a group. Each value in the
  object is an array containing the objects that fall into that group.