以下のような配列があるとします.
>>> $Users => [ [ "name" => "Tanaka", "age" => 16, ], [ "name" => "Hamada", "age" => 18, ], [ "name" => "Shimura", "age" => 12, ], ]
これをコレクションクラスを用いて年齢(降順)に並べる時は以下のように書くと良いです.
>>> collection($Users)->sortBy('age', SORT_DESC)->toArray(); => [ 1 => [ "name" => "Hamada", "age" => 18, ], 0 => [ "name" => "Tanaka", "age" => 16, ], 2 => [ "name" => "Shimura", "age" => 12, ], ]
SORT_DESCをSORT_ASCにすると昇順になります.