Skip to content

Commit be07697

Browse files
Fixed the reverse sort.
1 parent 19ad35c commit be07697

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Common/Collection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function first()
3333
*/
3434
public function last()
3535
{
36-
$array = array_reverse($this->items);
37-
return $array[0];
36+
$count = count($this->items);
37+
return $this->items[$count-1];
3838
}
3939

4040
/**
@@ -56,7 +56,7 @@ public function sortBy(string $fieldName, bool $reverse = false): CollectionInte
5656
return $item1[$fieldName] <=> $item2[$fieldName];
5757
});
5858
if ($reverse) {
59-
krsort($results);
59+
$results = array_reverse($results);
6060
}
6161
return new static($results);
6262
}

0 commit comments

Comments
 (0)