DaftMonk
/**
* Welcome to Tinkerwell!
*
* You can tinker using the built-in
* Laravel 7 application and use all the
* nice Laravel features right away.
*
* Try modifying this file - the changes will
* be automatically evaluated as you type.
*/
$movies = [
[
'name' => 'Back to the Future',
'released_in' => 1985,
],
[
'name' => 'Ghostbusters',
'released_in' => 1984,
]
];
collect($movies)
->sortBy(function ($movie) {
return Arr::get($movie, 'released_in');
})
->values()
->toArray();
=> [
[
"name" => "Ghostbusters",
"released_in" => 1984,
],
[
"name" => "Back to the Future",
"released_in" => 1985,
],
]