diff --git a/app/index.php b/app/index.php new file mode 100644 index 0000000000000000000000000000000000000000..c228b393803103d0ec5be9b660c939bc7deabfd1 --- /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 0000000000000000000000000000000000000000..2b7a69d848c955035584a0ca6ee0a78ae5b0547d --- /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