From bc3d5975c19445ed5a64a80a186356a91af8d278 Mon Sep 17 00:00:00 2001 From: Stream Date: Fri, 28 Apr 2017 14:34:29 +0800 Subject: [PATCH] folders in tree view should be sorted by names --- src/controllers/FolderController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controllers/FolderController.php b/src/controllers/FolderController.php index bb8b912d..5c101db7 100644 --- a/src/controllers/FolderController.php +++ b/src/controllers/FolderController.php @@ -29,10 +29,15 @@ public function getFolders() foreach ($folder_types as $folder_type => $lang_key) { $root_folder_path = parent::getRootFolderPath($folder_type); + $children = parent::getDirectories($root_folder_path); + usort($children, function ($a, $b) { + return strcmp($a->name, $b->name); + }); + array_push($root_folders, (object)[ 'name' => trans('laravel-filemanager::lfm.title-' . $lang_key), 'path' => parent::getInternalPath($root_folder_path), - 'children' => parent::getDirectories($root_folder_path), + 'children' => $children, 'has_next' => !($lang_key == end($folder_types)) ]); }