Skip to content

GroupBy improvement #55

@boudewijn-zicht

Description

@boudewijn-zicht

GroupBy currently uses sorting to efficiently group the data, however, this removes the original order of the data. Sometimes this is not preferred.

A new GroupBy strategy, i.e. ordered should be implemented.

For example:

$data = iterable([['key'=>'b'], ['key'=>'a'], ['key'=>'b']]);

$data->groupBy('key', 'SORT-STRATEGY')
// Result: ['a' => [['key'=>'a']], 'b' => [['key'=>'b'], ['key'=>'b']]]
// First the 'a' because it was sorted

$data->groupBy('key', 'ORDERED-STRATEGY')
// Result: ['b' => [['key'=>'b'], ['key'=>'b']], 'a' => [['key'=>'a']]]
// First the 'b' because the 'b' is first in $data

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions