diff --git a/modules/files_folders_functions/src/cpp/ListFiles.cpp b/modules/files_folders_functions/src/cpp/ListFiles.cpp index b4e35e6c79..daa28640d3 100644 --- a/modules/files_folders_functions/src/cpp/ListFiles.cpp +++ b/modules/files_folders_functions/src/cpp/ListFiles.cpp @@ -198,22 +198,22 @@ ListFiles(const std::wstring& directory, bool bSubdirectories) bool operator()(FileInfo a, FileInfo b) // lgtm [cpp/large-parameter] { - return a.getName() < b.getName(); + return static_cast(a.isDir()) > static_cast(b.isDir()); } - } customFilenameLess; + } customIsDirLess; if (!res.empty()) { - std::sort(res.begin(), res.end(), customFilenameLess); + std::sort(res.begin(), res.end(), customIsDirLess); } struct { bool operator()(FileInfo a, FileInfo b) // lgtm [cpp/large-parameter] { - return static_cast(a.isDir()) > static_cast(b.isDir()); + return a.getName() < b.getName(); } - } customIsDirLess; + } customFilenameLess; if (!res.empty()) { - std::sort(res.begin(), res.end(), customIsDirLess); + std::sort(res.begin(), res.end(), customFilenameLess); } } return res;