src/Set.php
public function groupBy(string $column): CollectionInterface
    {
        $return = [];

        foreach ($this->toArray() as $item) {
            if (isset($item[$column])) {
                $key = $item[$column];
                $return[$key] = $item;
            }
            // Must throw exception if item column does not exists
        }

        return new Collection($return);
    }
public function groupBy(string $column): CollectionInterface
    {
        $return = [];

        foreach ($this->toArray() as $item) {
            if (isset($item[$column])) {
                $key = $item[$column];
                $return[$key] = $item;
            }
            // Must throw exception if item column does not exists
        }

        return new Collection($return);
    }
public function groupBy ( string $ column ) : CollectionInterface { $ return = [ ] ; foreach ( $ this -> toArray ( ) as $ item ) { if ( isset ( $ item [ $ column ] ) ) { $ key = $ item [ $ column ] ; $ return [ $ key ] = $ item ; } // Must throw exception if item column does not exists } return new Collection ( $ return ) ; }
Returns a new Collection grouped by the specified column.

@todo MUST throw exception if the column does not exists

@param string $column The column to group by.

@return Collection A new collection instance.
Returns a new Collection grouped by the specified column .