Skip to content

Stream::sortBy дублирует элементы при совпадении значения #30

Description

@garr1nch4
class Item {

    private $value;

    public function __construct($value) {
        $this->value = $value;
    }

    public function getValue() {
        return $this->value;
    }

}

$items = [
    new Item(1),
    new Item(7),
    new Item(7),
];
$res = \WS\Utils\Collections\CollectionFactory::from($items)
    ->stream()
    ->map(function ($a) {
        return $a;
    })
    ->sortBy(function(Item $item) {
        return $item->getValue();
    })
    ->getCollection()
;

echo $res->size();

Output:

5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions