From aef9d107d7bbd3f8593344a0ebab7ace71545391 Mon Sep 17 00:00:00 2001 From: Justin Walsh Date: Fri, 21 Jun 2013 11:12:14 -0500 Subject: [PATCH] Fixed path sorting --- libs/functions.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libs/functions.php b/libs/functions.php index 02c7b21..2a379f4 100644 --- a/libs/functions.php +++ b/libs/functions.php @@ -202,8 +202,21 @@ function get_tree($path = '.', $clean_path = '', $title = ''){ $dh = @opendir($path); $index = 0; - // Loop through the directory + // Build array of paths + $paths = array(); while(false !== ($file = readdir($dh))){ + $paths[$file] = $file; + } + + // Close the directory handle + closedir($dh); + + // Sort paths + sort($paths); + + // Loop through the paths + // while(false !== ($file = readdir($dh))){ + foreach($paths as $file) { // Check that this file is not to be ignored if(!in_array($file, $ignore)) { @@ -245,9 +258,6 @@ function get_tree($path = '.', $clean_path = '', $title = ''){ $index++; } - // Close the directory handle - closedir($dh); - return $tree; } ?> \ No newline at end of file