feat: Sort tree

This commit is contained in:
Dendy 2025-04-14 07:23:12 +02:00
parent 7c955c481b
commit 1732106e7b
1 changed files with 13 additions and 0 deletions

View File

@ -78,6 +78,8 @@ final class MainController extends AbstractController
}
}
self::ksort_recursive($tree);
return $this->render('main/index.html.twig', [
'path' => $path,
'contents' => $text,
@ -113,4 +115,15 @@ final class MainController extends AbstractController
'text' => $nextIteration['text'],
];
}
private static function ksort_recursive(array &$array, int $sort_flags = SORT_REGULAR): void
{
ksort($array, $sort_flags);
foreach ($array as &$value) {
if (is_array($value)) {
self::ksort_recursive($value, $sort_flags);
}
}
}
}