according to
https://en.cppreference.com/w/cpp/experimental/fs/directory_iterator
The iteration order is unspecified, except that
How to go through the directory and sort the contents?
std::string html; for (auto & p : std::experimental::filesystem::directory_iterator(filepath)) { std::string current = format("<p><a href=""%s"">%s</a></p>", p.path().filename().c_str(), p.path().filename().c_str()); html += current; } It is desirable that this was such an order: first, all the folders in alphabetical order, then the files in alphabetical order.
The only solution at the moment is to first put folders into a vector of folders, files into files vector in the first pass through the directory, then sort vector1, vector2 and collect back into the resultant vector, but somehow cumbersome ...
std::setcontains unique objects. And files in different folders can have the same name. Thus, some of the files may disappear. - Alexander Petrov