Groups array of objects.
 Ex.:
 ar = %{ aaa abc bbb bab }
960635
def group_items(items, opts = {})
      default_opts          = {:group_size => 10, :header => proc { |c| c.to_s[0, 1].upcase }}
      opts                  = default_opts.merge(opts)
      group_size            = opts[:group_size]
      header                = opts[:header]

      items                 = items.sort_by &header
      items_group_by_header = items.group_by &header

      items_by_headers      = []
      merge_headers         = []
      merge_items           = []

      items_group_by_header.sort.each do |header, items|
        merge_headers << header
        merge_items.concat items
        if merge_items.length >= group_size
          items_by_headers << [merge_headers, merge_items]
          merge_headers = []
          merge_items   = []
        end
      end

      if merge_items.length > 0
        items_by_headers << [merge_headers, merge_items]
      end
      items_by_headers
    end
1267516
def _group(tlist, cls, match,
           valid_prev=lambda t: True,
           valid_next=lambda t: True,
           post=None,
           extend=True,
           recurse=True
           ):
    """"""

    tidx_offset = 0
    pidx, prev_ = None, None
    for idx, token in enumerate(list(tlist)):
        tidx = idx - tidx_offset

        if token.is_whitespace:
            continue

        if recurse and token.is_group and not isinstance(token, cls):
            _group(token, cls, match, valid_prev, valid_next, post, extend)

        if match(token):
            nidx, next_ = tlist.token_next(tidx)
            if prev_ and valid_prev(prev_) and valid_next(next_):
                from_idx, to_idx = post(tlist, pidx, tidx, nidx)
                grp = tlist.group_tokens(cls, from_idx, to_idx, extend=extend)

                tidx_offset += to_idx - from_idx
                pidx, prev_ = from_idx, grp
                continue

        pidx, prev_ = tidx, token
1174461
def _getgroup(string, depth):
    
    out, comma = [], False
    while string:
        items, string = _getitem(string, depth)

        if not string:
            break
        out += items

        if string[0] == '}':
            if comma:
                return out, string[1:]
            return ['{' + a + '}' for a in out], string[1:]

        if string[0] == ',':
            comma, string = True, string[1:]

    return None
12387
function countBy (obj, iterate, context) {
  var result = groupBy(obj, iterate, context || this)
  objectEach(result, function (item, key) {
    result[key] = item.length
  })
  return result
}
1045418
function group (frame) {
        let v, name, op;
        const entries = fields.map((field, index) => {
            name = ops[index];
            op = scalar_operations.get('count');
            if (name) {
                op = scalar_operations.get(name);
                if (!op) {
                    op = scalar_operations.get('count');
                    warn(`Operation ${name} is not supported, use count`);
                }
            }
            return {
                field: field,
                as: as[index] || field,
                op: op
            };
        });

        return frame.dimension(groupby).group().reduce((o, record) => {
            return entries.reduce((oo, entry) => {
                v = 0;
                if (entry.as in oo) v = oo[entry.as];
                oo[entry.as] = entry.op(v, record[entry.field]);
                return oo;
            }, o);
        }, null, Object).all().map(d => {
            d.value[groupby] = d.key;
            return d.value;
        });
    }
453988
function group() {                              // experimental
   var o,i=0,a=arguments; 
   if(a[0].length) a = a[0]; 
   
   if((typeof(a[i]) == "object") && (a[i] instanceof CAG)) {
      o = a[i].extrude({offset: [0,0,0.1]});    // -- convert a 2D shape to a thin solid, note: do not a[i] = a[i].extrude()
   } else {
      o = a[i++];                               
   }
   for(; i<a.length; i++) { 
      var obj = a[i];
      if((typeof(a[i]) == "object") && (a[i] instanceof CAG)) {
         obj = a[i].extrude({offset: [0,0,0.1]});    // -- convert a 2D shape to a thin solid:
      }
      o = o.unionForNonIntersecting(obj); 
   } 
   return o; 
}
1021842
function aggregateParams(_, pulse) {
  var key    = _.field,
  value  = _.value,
      op     = (_.op === 'count' ? '__count__' : _.op) || 'sum',
      fields = accessorFields(key).concat(accessorFields(value)),
      keys   = pivotKeys(key, _.limit || 0, pulse);

  return {
    key:      _.key,
    groupby:  _.groupby,
    ops:      keys.map(function() { return op; }),
    fields:   keys.map(function(k) { return get(k, key, value, fields); }),
    as:       keys.map(function(k) { return k + ''; }),
    modified: _.modified.bind(_)
  };
}
256827
def group_ids=(values)
      values ||= []
      values = [ values ] unless values.is_a?(::Array)
      values = values.reject{|v| v.blank?}.map{|v| v.to_i}
      self.groups = Incline::AccessGroup.where(id: values).to_a
    end
852495
def group(prefix, name, options = {})
      subtree = self.class.new
      yield(subtree) if block_given?

      merge(subtree, prefix, name, options)
    end
560796
def build_grouping_body
      arr = []
      data.each do |_,group|                     
        arr << render_group(group, options)
      end
      output << arr.join(",\n")
    end
1202772
def group_constants(constants)
      grouped = Hash.new { |hash, key| hash[key] = [] }

      constants.each do |name|
        root           = name.split('::')[0]
        grouped[root] << name
      end

      return grouped
    end
636041
def array_wrap(object)
      if object.nil?
        []
      elsif object.respond_to?(:to_ary)
        object.to_ary || [object]
      else
        [object]
      end
    end
1180387
private void addGroup(String key, Group object) {
    int fieldIndex = getIndex(key);
    this.schema.getType(fieldIndex).asGroupType();
    this.data[fieldIndex].add(object);
  }
500521
function groupData(data, dim) {
    var groups = {};

    each(data, function (record) {
      var value = record[dim];
      if (value === undefined) {
        value = record[dim] = DEFAULT_Y;
      }
      if (!groups[value]) {
        groups[value] = [];
      }
      groups[value].push(record);
    });

    return groups;
  }
1206794
def _group(self, rdd):
        """"""
        return rdd.reduceByKey(lambda x, y: x.append(y))
546133
function groupFieldsByType(list){
    var fields = {};
    _.each(list.fields, function(v,k) {
        if (! fields.hasOwnProperty(v.type)) fields[v.type] = [];
        fields[v.type].push(v);
    });
    return fields;
}
1165555
def groupBy(self, val):
        

        def by(result, key, value):
            if key not in result:
                result[key] = []
            result[key].append(value)

        res = self._group(self.obj, val, by)

        return self._wrap(res)