> I need something like a "sortfunction" because i want to sort the files
in a directory x by name or date. i can't find any system function in
c++ - any ideas, examples??
Hmm.. what about std::sort?
# include <algorithm>
class File
{
};
void by_name(std::vector<File> &files)
{
std::sort(files.begin(), files.end());
}
bool date_compare(const File &f1, const File &f2)
{
if ( f1.date() < f2.date() )
return true;
return false;
}
void by_date(std::vector<File> &files)
{
std::sort(files.begin(), files.end(), date_compare);
}
Jonathan