Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel sort collection

$collection = collect([5, 3, 1, 2, 4]);

$sorted = $collection->sortDesc();

$sorted->values()->all();

// [5, 4, 3, 2, 1]
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #laravel #sort #collection
ADD COMMENT
Topic
Name
2+3 =