Sort folders and files in file browser

This commit is contained in:
JonnyWong16
2020-05-03 17:13:17 -07:00
parent 209008e50d
commit 12effd643f

View File

@@ -1229,7 +1229,7 @@ def browse_path(path=None, include_hidden=False, filter_ext=''):
output.append(out) output.append(out)
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for d in dirs: for d in sorted(dirs):
if not include_hidden and d.startswith('.'): if not include_hidden and d.startswith('.'):
continue continue
dir_path = os.path.join(root, d) dir_path = os.path.join(root, d)
@@ -1241,7 +1241,7 @@ def browse_path(path=None, include_hidden=False, filter_ext=''):
'icon': 'folder' 'icon': 'folder'
} }
output.append(out) output.append(out)
for f in files: for f in sorted(files):
if not include_hidden and f.startswith('.'): if not include_hidden and f.startswith('.'):
continue continue
if filter_ext and not f.endswith(filter_ext): if filter_ext and not f.endswith(filter_ext):