Skip to content

Commit febcb3c

Browse files
themsaidtaylorotwell
authored andcommitted
revert PR 21214 (#21255)
1 parent 5cefb9d commit febcb3c

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/Illuminate/Support/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ public function sortBy($callback, $options = SORT_REGULAR, $descending = false)
13481348
// function which we were given. Then, we will sort the returned values and
13491349
// and grab the corresponding values for the sorted keys from this array.
13501350
foreach ($this->items as $key => $value) {
1351-
$results[$key] = [$callback($value, $key), $key];
1351+
$results[$key] = $callback($value, $key);
13521352
}
13531353

13541354
$descending ? arsort($results, $options)

tests/Support/SupportCollectionTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,11 @@ public function testSortByString()
798798
$data = $data->sortBy('name');
799799

800800
$this->assertEquals([['name' => 'dayle'], ['name' => 'taylor']], array_values($data->all()));
801+
802+
$data = new Collection([['name' => 'taylor'], ['name' => 'dayle']]);
803+
$data = $data->sortBy('name', SORT_STRING);
804+
805+
$this->assertEquals([['name' => 'dayle'], ['name' => 'taylor']], array_values($data->all()));
801806
}
802807

803808
public function testSortByAlwaysReturnsAssoc()
@@ -817,15 +822,6 @@ public function testSortByAlwaysReturnsAssoc()
817822
$this->assertEquals([1 => 'dayle', 0 => 'taylor'], $data->all());
818823
}
819824

820-
public function testSortByMaintainsOriginalOrderOfItemsWithIdenticalValues()
821-
{
822-
$data = new Collection([['name' => 'taylor'], ['name' => 'dayle'], ['name' => 'dayle']]);
823-
$data = $data->sortBy('name');
824-
825-
$this->assertEquals([['name' => 'dayle'], ['name' => 'dayle'], ['name' => 'taylor']], array_values($data->all()));
826-
$this->assertEquals([1, 2, 0], $data->keys()->all());
827-
}
828-
829825
public function testReverse()
830826
{
831827
$data = new Collection(['zaeed', 'alan']);

0 commit comments

Comments
 (0)