Level 29
https://laravel.com/docs/9.x/collections#method-sortby
Example
->sortBy(fn($item,$key)=>$item['ek_price']+$item['shopping_cost']);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
->orderBy(DB::raw("ek_price + shipping_cost"), 'asc')
this is my orderby
now i want to use sortby sum like orderby in my collection ```
Please or to participate in this conversation.