public function mapToGroups(callable $callback)
    {
        $groups = $this->map($callback)->reduce(function ($groups, $pair) {
            $groups[key($pair)][] = reset($pair);

            return $groups;
        }, []);

        return (new static($groups))->map([$this, 'make']);
    }
public function mapToGroups(callable $callback)
    {
        $groups = $this->map($callback)->reduce(function ($groups, $pair) {
            $groups[key($pair)][] = reset($pair);

            return $groups;
        }, []);

        return (new static($groups))->map([$this, 'make']);
    }
public function mapToGroups ( callable $ callback ) { $ groups = $ this -> map ( $ callback ) -> reduce ( function ( $ groups , $ pair ) { $ groups [ key ( $ pair ) ] [ ] = reset ( $ pair ) ; return $ groups ; } , [ ] ) ; return ( new static ( $ groups ) ) -> map ( [ $ this , 'make' ] ) ; }
Run a grouping map over the items.

The callback should return an associative array with a single key/value pair.

@param callable $callback

@return static
Run a grouping map over the items .