I have the following struct definition:
struct finfo {
string filename;
long fsize;
bool operator() (finfo i, finfo j){return (i.fsize > j.fsize);}
} fstruct;
And the following vector definition:
vector<finfo> fdata;
In the code I use the following statement to sort the vector elements by fsize:
sort(fdata.begin(),fdata.end(),fstruct);
This works perfectly well, but how can I sort by the field "filename" when i.fsize = j.fsize ?
(The vector is filled by reading directory information, and putting the filenames and filesizes in the appropriate fields in the struct. If the filesize is equal I want to sort the files alphabetically by file name (the field filename).