public function groupBy($strategy, $sort = true)
    {
        if (!is_bool($sort)) {
            throw new \InvalidArgumentException('Argument $sort must be a boolean');
        }

        if ($this instanceof \Iterator) {
            return new GroupbyIterator(
                conversions\mixed_to_value_getter($strategy),
                $sort ? $this->sorted($strategy) : $this
            );
        }

        return null;
    }