Skip to content
Snippets Groups Projects
Functions.php 546 B
Newer Older
Адлан Шамавов's avatar
Адлан Шамавов committed
<?php

declare(strict_types=1);

namespace App\Action;

class Functions
{
    /**
     * Выполняет сортировку массива по убыванию цены
     * @param array $array
     * @return array
     */
    public function sortPrice(array $array): array
    {
        $prices = array_column($array, 'price');
        $counts = array_column($array, 'count');
        array_multisort(
            $prices,
            SORT_DESC,
            $counts,
            SORT_ASC, $array
        );
        return $array;
    }
}