$items Array of objects with a price property to sort * * @return array The sorted array of objects (ascending by price) */ protected function sortByPrice(array $items): array { uasort($items, function (object $a, object $b) { $priceA = $a->price ?? 0; $priceB = $b->price ?? 0; return $priceA <=> $priceB; }); return $items; } }