Laravel - Collections - Method Sortdesc
This method will sort the collection in the opposite order as the sort
method:
$collection = collect([5, 3, 1, 2, 4]);
$sorted = $collection->sortDesc();
$sorted->values()->all();
// [5, 4, 3, 2, 1]
Unlike sort
, you may not pass a closure to sortDesc
. Instead, you should use the sort
method and invert your comparison.