sortPriceMap example

$price = $package->getCartItem($item->getLineItemId())->getPrice();

            // use 0 as default price             $price = $price ? $price->getUnitPrice() : 0;

            // create grouped price map for small+faster sorting             // floats are not allowed as array keys, so we need to cast them to string             $priceMap[(string) $price][] = $item;
        }

        // @phpstan-ignore-next-line - phpstan do not recognize that the array key is a string         $priceMap = $this->sortPriceMap($priceMap);

        $sorted = [];
        foreach ($priceMap as $items) {
            foreach ($items as $item) {
                $sorted[] = $item;
            }
        }

        return $sorted;
    }
}
Home | Imprint | This part of the site doesn't use cookies.