Skip to content

Commit 0f2db14

Browse files
committed
Fix. Sorting with extraction function inside
1 parent fdc961e commit 0f2db14

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Collections library for php language",
44
"minimum-stability": "dev",
55
"license": "MIT",
6-
"version": "1.1.6",
6+
"version": "1.1.7",
77
"authors": [
88
{
99
"name": "Maxim Sokolovsky",

src/WS/Utils/Collections/SerialStream.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ public function sortBy(callable $extractor): Stream
137137
sort($values);
138138
$newList = $this->emptyList();
139139
foreach ($values as $value) {
140-
$els = $map[$value.''] ?? [];
140+
$key = $value.'';
141+
$els = $map[$key] ?? [];
141142
$newList->addAll($els);
143+
unset($map[$key]);
142144
}
143145
$this->list = $newList;
144146

tests/WS/Utils/Collections/SerialStreamTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ public function sortingWithExtractor($input, $min, $max): void
480480

481481
$this->assertEquals($min, $actualMin->getValue());
482482
$this->assertEquals($max, $actualMax->getValue());
483+
$this->assertEquals(count($input), $sortedCollection->size());
483484
}
484485

485486
/**

0 commit comments

Comments
 (0)