diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index b720671..b231638 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -1103,10 +1103,19 @@ bool load_images_from_dir(const std::string dir, return false; } + std::vector entries; for (const auto& entry : fs::directory_iterator(dir)) { - if (!entry.is_regular_file()) - continue; + if (entry.is_regular_file()) { + entries.push_back(entry); + } + } + std::sort(entries.begin(), entries.end(), + [](const fs::directory_entry& a, const fs::directory_entry& b) { + return a.path().filename().string() < b.path().filename().string(); + }); + + for (const auto& entry : entries) { std::string path = entry.path().string(); std::string ext = entry.path().extension().string(); std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);