From 0b9efc04b56af53425afdc27b20ac0ad142ca9ab Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 4 Jul 2020 20:33:23 +0200 Subject: [PATCH] LibGUI: Sort FileSystemModel alphabetically internally This just makes everything nicer. --- Libraries/LibGUI/FileSystemModel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/FileSystemModel.cpp b/Libraries/LibGUI/FileSystemModel.cpp index 71ee61b09cf..0d9fad32a0e 100644 --- a/Libraries/LibGUI/FileSystemModel.cpp +++ b/Libraries/LibGUI/FileSystemModel.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include @@ -97,8 +98,13 @@ void FileSystemModel::Node::traverse_if_needed(const FileSystemModel& model) return; } + Vector child_names; while (di.has_next()) { - String name = di.next_path(); + child_names.append(di.next_path()); + } + quick_sort(child_names); + + for (auto& name : child_names) { String child_path = String::format("%s/%s", full_path.characters(), name.characters()); NonnullOwnPtr child = make(); bool ok = child->fetch_data(child_path, false);