private function getGridForCountry(CountryInterface $country)
    {
        if (isset($this->grids[$country->getId()])) {
            return $this->grids[$country->getId()];
        }

        $grid = [];

        $prices = $this->priceRepository->findByCountry($country);
        foreach ($prices as $price) {
            $method = $price->getMethod();

            // Create method if not exists
            if (!isset($grid[$method->getId()])) {
                $gateway = $this->gatewayRegistry->getGateway($method->getGatewayName());

                $grid[$method->getId()] = [
                    'method'     => $method,
                    'max_weight' => $gateway->getMaxWeight(),
                    'prices'     => [],
                ];
            }

            // Add price
            $grid[$method->getId()]['prices'][] = [
                'weight' => $price->getWeight(),
                'price'  => $price->getNetPrice(),
            ];
        }

        foreach ($grid as &$method) {
            // Sort prices by weight ASC
            usort($method['prices'], function ($a, $b) {
                if (0 === bccomp($a['weight'], $b['weight'], 3)) {
                    return 0;
                }

                return $a['weight'] > $b['weight'] ? 1 : -1;
            });

            // Fix max weight
            $max = end($method['prices'])['weight'];
            if (0 == $method['max_weight'] || $method['max_weight'] > $max) {
                $method['max_weight'] = $max;
            }

            unset($method);
        }

        return $this->grids[$country->getId()] = $grid;
    }
private function getGridForCountry(CountryInterface $country)
    {
        if (isset($this->grids[$country->getId()])) {
            return $this->grids[$country->getId()];
        }

        $grid = [];

        $prices = $this->priceRepository->findByCountry($country);
        foreach ($prices as $price) {
            $method = $price->getMethod();

            // Create method if not exists
            if (!isset($grid[$method->getId()])) {
                $gateway = $this->gatewayRegistry->getGateway($method->getGatewayName());

                $grid[$method->getId()] = [
                    'method'     => $method,
                    'max_weight' => $gateway->getMaxWeight(),
                    'prices'     => [],
                ];
            }

            // Add price
            $grid[$method->getId()]['prices'][] = [
                'weight' => $price->getWeight(),
                'price'  => $price->getNetPrice(),
            ];
        }

        foreach ($grid as &$method) {
            // Sort prices by weight ASC
            usort($method['prices'], function ($a, $b) {
                if (0 === bccomp($a['weight'], $b['weight'], 3)) {
                    return 0;
                }

                return $a['weight'] > $b['weight'] ? 1 : -1;
            });

            // Fix max weight
            $max = end($method['prices'])['weight'];
            if (0 == $method['max_weight'] || $method['max_weight'] > $max) {
                $method['max_weight'] = $max;
            }

            unset($method);
        }

        return $this->grids[$country->getId()] = $grid;
    }
Returns the price grid for the given country.

@param CountryInterface $country

@return array|mixed