Generate an array with elements grouped by groups (...).

@param string $pointer
@return array
182045
public function forEachGroups($pointer)
    {
        $data = [];
        foreach ($this->evalGroupFields($this->config->getPointer($pointer)) as $group) {
            $data[] = [
                'fields' => $this->config->getFields($pointer, $group[0]),
                'name' => $group[1],
                'collapsed' => isset($group['collapsed']) ? (bool) $group['collapsed'] : false,
                'is_default' => isset($group['is_default']) ? (bool) $group['is_default'] : false,
            ];
        }
        
        return $data;
    }
534359
public function group($property)
    {
        $list = [];

        /** @var ObjectInterface $element */
        foreach ($this->getIterator() as $element) {
            $list[(string) $element->getProperty($property)][] = $element;
        }

        return $list;
    }
1130945
public function partition($callback): array
    {
        $partitions = [[], []];
        foreach ($this->generator as $key => $item) {
            if ($this->accessKey($item, $callback, $key)) {
                $partitions[0][$key] = $item;
            } else {
                $partitions[1][$key] = $item;
            }
        }

        return array_map(function ($value) {
            return $this::make($value);
        }, $partitions);
    }
1035152
public static function toArrayRecursive($collection) {
		$arr = $collection;
		if (is_object($collection) && method_exists($collection, 'toArray')) {
			$arr = $collection->toArray();
		}

		return array_map(function ($v) {
			if (is_object($v) && method_exists($v, 'toArray')) {
				return static::toArrayRecursive($v);
			}
			return $v;
		}, $arr);
	}
857634
private function evaluatePointerParts(array $pointerParts)
    {
        $searchables = array('~1', '~0');
        $evaluations = array('/', '~');

        $parts = array();
        array_filter($pointerParts, function ($v) use (&$parts, &$searchables, &$evaluations) {
            return $parts[] = str_replace($searchables, $evaluations, $v);
        });
        return $parts;
    }
38007
public function createObjectStateGroupListFromData(array $data)
    {
        $objectStateGroups = array();

        foreach ($data as $objectStateGroupData) {
            $objectStateGroups[] = $this->createObjectStateGroupFromData($objectStateGroupData);
        }

        return $objectStateGroups;
    }
601033
public static function groupBy($collection = null, $iterator = null)
    {
        $result = array();
        $collection = (array) $collection;
        foreach ($collection as $k => $item) {
            if (is_object($iterator) && is_callable($iterator)) {
                $key = $iterator($item, $k);
            } elseif (is_object($item)) {
                $key = $item->$iterator;
            } elseif (is_array($item)) {
                $key = $item[$iterator];
            }
            
            if (!array_key_exists($key, $result)) {
                $result[$key] = array();
            }
            $result[$key][$k] = $item;
        }
        return $result;
    }
8135
public function getIterator()
    {
        $array = [];
        foreach (array_keys($this->imports) as $group) {
            $array[$group] = $this->offsetGet($group);
        }

        return new ArrayIterator($array);
    }
332514
public function group_by( $key ) 
	{
		if ( !is_array( $key ) )
		{
			$key = array( $key );	
		}
		
		foreach( $key as $group_key )
		{
			$this->groups[] = $group_key;
		}
		
		return $this;
	}
990067
private static function groupBy($array) {
        $origin = $array;
        if(count($array) > 1) {
            self::calls(array_shift($array));
        }
        return ' GROUP BY ' . $origin[0] . (intval($origin[1]) > 0 ? ', ' . $origin[1] : '');
    }
470026
public static function build(array $pointer, array $context)
    {
        if (array_key_exists('value', $pointer)) {
            return $pointer['value'];
        }
        if (!empty($pointer['classname'])) {
            $classname = NameResolver::resolve($pointer['classname'], $context);
            return self::buildByClassname($classname, $pointer, $context);
        }
        if (!empty($pointer['creator'])) {
            return Callback::call($pointer['creator'], [$pointer, $context]);
        }
        if (!empty($context['classname'])) {
            return self::buildByClassname($context['classname'], $pointer, $context);
        }
        if (!empty($context['creator'])) {
            return Callback::call($context['creator'], [$pointer, $context]);
        }
        throw new InvalidPointer('');
    }
188759
private function generateListByIterator(Iterator $iterator)
    {
        $resultado = array();
        foreach ($iterator as $compra) {
            $resultado[] = $this->preencherCompra($compra);
        }

        return $resultado;
    }
234381
public function toArray(): array
    {
        return array_filter([
            'aggregations' => array_map(function (Aggregation $aggregation) {
                return $aggregation->toArray();
            }, $this->getAggregations()),
            'total_elements' => $this->getTotalElements(),
        ]);
    }
4917
public static function groupByType(array $objects)
    {
        $perType = [];
        foreach ($objects as $object) {
            $type = $object->getType();
            if (!isset($perType[$type])) {
                $perType[$type] = [];
            }
            $perType[$type][] = $object;
        }
        return $perType;
    }
341607
public function groupBy($iterator) : Collection
    {
        $rslt = [];
        $temp = $this->toArray();
        foreach ($temp as $k => $v) {
            $rslt[is_string($iterator) ? (is_object($v) ? $v->{$iterator} : $v[$iterator]) : call_user_func($iterator, $v, $k)][] = $v;
        }
        return new static($rslt);
    }
360900
protected function getObjectAt($pointer)
    {
        if ($this->queryResult->getRecord($pointer)) {
            $this->current = $this->queryResult->getRecord($pointer);

            foreach ($this->current as $key => &$value) {
                if ($value instanceof QueryResult) {
                    $value = new RecordIterator($this->client, $value);
                }
            }

            return $this->current;
        }

        // If no record was found at pointer, see if there are more records
        // available for querying
        if (!$this->queryResult->isDone()) {
            $this->queryMore();

            return $this->getObjectAt($this->pointer);
        }
    }
382458
public function groupBy($set, $groupingKey)
    {
        $result = [];
        foreach ($set as $element) {
            $result[ObjectAccess::getPropertyPath($element, $groupingKey)][] = $element;
        }

        return $result;
    }