Newer
Older
<?php
namespace Hp\Test;
use DateTimeImmutable;
use DateTime;
use DateInterval;
use DatePeriod;
class Functions {
/**
* Выполняет сортировку массива по убыванию цены *
* @param array $array *
* @return array
*/
function sortPrice(array $array): array {
array_multisort(array_column($array, 'price'), SORT_DESC, array_column($array, 'count'), SORT_ASC, $array);
return $array;
}
//На выход должна вернуть отсортированный массив по ключу *price* DESC и во вторую очередь по *count* ASC:
//[ ['price'=>12, 'count'=>4], ['price'=>10, 'count'=>2], ['price'=>8, 'count'=>4],
//['price'=>8, 'count'=>5], ['price'=>5, 'count'=>5], ]