/**
* {@inheritDoc}
* @return $this
*/
public function groupBy($callback)
{
$callback = $this->propertyExtractor($callback);
$group = new Dictionary();
foreach ($this as $value) {
$key = $callback($value);
if (!$group->containsKey($key)) {
$element = $this instanceof VectorInterface ? new static([$value]) : new ArrayList([$value]);
$group->add($key, $element);
} else {
$value = $group->get($key)->add($value);
$group->set($key, $value);
}
}
return $group;
}