From bf1c5370548a7e828837f581cdd95c8ffdc7e61f Mon Sep 17 00:00:00 2001 From: Akex Date: Thu, 4 Apr 2024 11:03:54 +0500 Subject: [PATCH] first task done --- app/index.php | 10 ++++++++++ app/repository/SortPrice.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 app/index.php create mode 100644 app/repository/SortPrice.php diff --git a/app/index.php b/app/index.php new file mode 100644 index 0000000..c228b39 --- /dev/null +++ b/app/index.php @@ -0,0 +1,10 @@ +10, 'count'=>2], ['price'=>5, 'count'=>5], ['price'=>8, 'count'=>5], ['price'=>12, 'count'=>4], ['price'=>8, 'count'=>4], ]; +$array = sortPrice($array); +var_dump($array); + + + + diff --git a/app/repository/SortPrice.php b/app/repository/SortPrice.php new file mode 100644 index 0000000..2b7a69d --- /dev/null +++ b/app/repository/SortPrice.php @@ -0,0 +1,31 @@ + $item){ + asort($item); + foreach ($item as $oneOfItem){ + $returnableArray[] = [ + [ + 'price'=>$key, + 'count'=>$oneOfItem + ] + ]; + } + } + + return $returnableArray; +} \ No newline at end of file -- GitLab