feat: Sort tree
This commit is contained in:
parent
7c955c481b
commit
1732106e7b
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue