Skip to content
Snippets Groups Projects

Ptps|controller 1

Merged Александр Плохих requested to merge PTPS|Controller_1 into main
3 files
+ 102
0
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 31
0
<?php
namespace App\Actions;
use App\Entity\InterfaceDataEntity;
class SortPriceAction implements InterfaceAction
{
/**
* Выполняет сортировку массива по убыванию цены
* @param InterfaceDataEntity $model
* @return array отсортированный
*/
public function act(InterfaceDataEntity $model): array
{
$array = $model->prices;
$priceColumn = array_column($array, "price");
$countColumn = array_column($array, "count");
array_multisort(
$priceColumn,
SORT_DESC,
$countColumn,
SORT_ASC,
$array,
);
return $array;
}
}
Loading