sortbydesc sur une collection laravel
$response = $f_games->merge($s_games)->sortByDesc('id')->values();
Attractive Ape
$response = $f_games->merge($s_games)->sortByDesc('id')->values();
$collection = collect([5, 3, 1, 2, 4]);
$sorted = $collection->sortDesc();
$sorted->values()->all();
// [5, 4, 3, 2, 1]
$posts = Post::orderBy('id', 'DESC')->get();
$collection = collect([5, 3, 1, 2, 4]);
$sorted = $collection->sort();
$sorted->values()->all();
// [1, 2, 3, 4, 5]
$results = Project::orderBy('name')->get();
$go = $go->sort(function ($a, $b) use ($order) {
$pos_a = array_search($a->colour, $order);
$pos_b = array_search($b->colour, $order);
return $pos_a - $pos_b;
});