Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d70a0b

Browse files
[Finder] fix reverse sorting custom-ordering functions
1 parent 0ea1adf commit 4d70a0b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Finder/Iterator/SortableIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder =
7373
} elseif (self::SORT_BY_NONE === $sort) {
7474
$this->sort = $order;
7575
} elseif (\is_callable($sort)) {
76-
$this->sort = $sort;
76+
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -\call_user_func($sort, $a, $b); } : $sort;
7777
} else {
7878
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
7979
}

0 commit comments

Comments
 (0)