Ignore Case When Using sortBy in Laravel


Laravel's sortBy() function allows you to sort data, taking case sensitivity into account by default. If you wish to intentionally disable this distinction, you can do so using the parameters SORT_NATURAL|SORT_FLAG_CASE. Here's a practical example:

$customers = Customer::all()->sortBy( 'name', SORT_NATURAL|SORT_FLAG_CASE );

It's important to note that the sortBy() function accepts the same parameters as PHP's native sort() function. A comprehensive overview of all available parameters can be found here.