/**
* @param array<LineItemQuantity> $metaItems
*
* @return array<LineItemQuantity>
*/
private function _sort(array
$metaItems, DiscountPackage
$package): array
{ $priceMap =
[];
foreach ($metaItems as $item) { $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);