diff --git a/src/Action/Functions.php b/src/Action/Functions.php
index d40b98045f01db19b9b9271537b11abda02dcf1c..dad8f178b82453b88c5164c0869b905af9b4bbbe 100644
--- a/src/Action/Functions.php
+++ b/src/Action/Functions.php
@@ -44,4 +44,44 @@ class Functions
         }
         return null;
     }
+
+    /**
+     * Удалить дубликаты, оставив только уникальные значения
+     * @param array $array
+     * @return array
+     */
+    public function uniqElements(array $array): array
+    {
+        return array_unique($array, SORT_REGULAR);
+    }
+
+    /**
+     * Сгруппировать подразедлы в верхние разделы меню
+     * Дочерние элементы поместить в массив родителя с ключом submenu
+     * Значение под ключом depth определяет уровень раздела
+     * Массив $aMenu всегда начинается с элемента depth = 0,
+     * все последующие элементы с depth = 1 являются его дочерними
+     * элементами
+     * @param array $aMenu
+     * @return array
+     */
+    public function prepareMenu(array $aMenu): array
+    {
+        $result = [];
+        foreach ($aMenu as $arr) {
+            if ($arr['depth'] == 0) {
+                $result[] = array(
+                    'name' => $arr['name'],
+                    'depth' => $arr['depth'],
+                    'submenu' => []
+                );
+                continue;
+            }
+            $result[array_key_last($result)]['submenu'][] = array(
+                'name' => $arr['name'],
+                'depth' => $arr['depth'],
+            );
+        }
+        return $result;
+    }
 }
\ No newline at end of file
diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php
index 8d0a83a99f6641a98961a357e773ce986b5260b2..d935b915124a1acc54eb63fdc5f61aecabacb48c 100644
--- a/src/Controller/HomeController.php
+++ b/src/Controller/HomeController.php
@@ -5,7 +5,9 @@ namespace App\Controller;
 use App\Action\Functions;
 use App\Requests\{
     SortPriceRequest,
-    SearchRequest
+    SearchRequest,
+    UniqElementsRequest,
+    MenuRequest
 };
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\Response;
@@ -37,4 +39,11 @@ class HomeController extends AbstractController
         $result = $this->functions->uniqElements($request->getRequest()->toArray()['items']);
         return $this->json($result);
     }
+
+    #[Route('/prepareMenu', name: 'prepareMenu', methods: ['POST'])]
+    public function prepareMenu(MenuRequest $request): Response
+    {
+        $result = $this->functions->prepareMenu($request->getRequest()->toArray()['items']);
+        return $this->json($result);
+    }
 }
diff --git a/src/Requests/MenuRequest.php b/src/Requests/MenuRequest.php
new file mode 100644
index 0000000000000000000000000000000000000000..e012d1336f70877e112dd24c60320ef96a500e55
--- /dev/null
+++ b/src/Requests/MenuRequest.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Requests;
+
+use Symfony\Component\Validator\Constraints as Assert;
+
+class MenuRequest extends BaseRequest
+{
+    #[Assert\All([
+        new Assert\Collection([
+            'name' => new Assert\Type('string'),
+            'depth' => new Assert\Type('int'),
+        ])
+    ])]
+    public array $items;
+}
\ No newline at end of file
diff --git a/templates/home.html.twig b/templates/home.html.twig
index 60456d99db53f4677fae8ee380f7050ccf1853fb..9baaf00b56202c0678d0032d0311ab647a9fe3a5 100644
--- a/templates/home.html.twig
+++ b/templates/home.html.twig
@@ -1,12 +1,12 @@
 {% block body %}
-    <h1>Сортировка массива:</h1>
-    <form method="POST">
-        {{ dump(array) }}
-        {% for key1, value1 in array %}
-            {% for key2, value2 in value1 %}
-                <input type="hidden" name="array[][]" value="{{ value2 }}">
+    <ul>
+    {% for value in menu %}
+        {% if value.depth == 0 %}
+            <h2>{{ value.name }}</h2>
+            {% for val in value.submenu %}
+                <li>{{ val.name }}</li>
             {% endfor %}
-        {% endfor %}
-        <button type="submit">Отправить массив</button>
-    </form>
+        {% endif %}
+    {% endfor %}
+    </ul>
 {% endblock %}
\ No newline at end of file