From c34164f071e30bd70652e780467cc31cb4ea18ad Mon Sep 17 00:00:00 2001 From: James Gordon Date: Tue, 6 Mar 2018 00:55:50 +1100 Subject: [PATCH] FileSystem returns files and directories sorted by name (#23387) --- src/Illuminate/Filesystem/Filesystem.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Filesystem/Filesystem.php b/src/Illuminate/Filesystem/Filesystem.php index 75ce9d08e70b..65bd61ba430f 100644 --- a/src/Illuminate/Filesystem/Filesystem.php +++ b/src/Illuminate/Filesystem/Filesystem.php @@ -387,7 +387,7 @@ public function glob($pattern, $flags = 0) public function files($directory, $hidden = false) { return iterator_to_array( - Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->depth(0), + Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->depth(0)->sortByName(), false ); } @@ -402,7 +402,7 @@ public function files($directory, $hidden = false) public function allFiles($directory, $hidden = false) { return iterator_to_array( - Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory), + Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->sortByName(), false ); } @@ -417,7 +417,7 @@ public function directories($directory) { $directories = []; - foreach (Finder::create()->in($directory)->directories()->depth(0) as $dir) { + foreach (Finder::create()->in($directory)->directories()->depth(0)->sortByName() as $dir) { $directories[] = $dir->getPathname(); }