Order of files in file system order is random (maybe different for every
user). Determinsm is good, i.e. when loading Nasal scripts in a fixed,
known sequence, or config files, where the later may overrule settings of
the earlier.
#include <cstring>
#include <cstdlib>
#include <iostream>
+#include <algorithm> // for std::sort
using std::string;
#endif
}
+static bool pathSortPredicate(const SGPath& p1, const SGPath& p2)
+{
+ return p1.file() < p2.file();
+}
+
PathList Dir::children(int types, const std::string& nameFilter) const
{
PathList result;
closedir(dp);
#endif
+
+ // File system order is random. Make things deterministic,
+ // so it's the same for every user.
+ std::sort(result.begin(), result.end(), pathSortPredicate);
+
return result;
}