I tried using a class based vector for sorting more than one column. Let's just say I have a lot of code that uses that struct and going to class-based caused a lot of problems.
My next thought was make the first column in the struct a "catch all" in which to hold my data in the order I wanted sorted.
I've tried that in the below code to no avail. It runs fine but not sorted.
Code:
struct record
{
std::string sortvalue;
std::string corp;
std::string lastname;
std::string firstname;
std::string lwi;
std::string grade;
std::string tanf;
std::string ssn;
};
std::vector<nsSVector::record*>::iterator start = schoolvector.begin();
std::vector<nsSVector::record*>::iterator stop = schoolvector.end();
while (start != stop)
{
if (VD.validateCorp((*start)->corp) == 0)
{
VD.validateNames("LAST",(*start)->lastname);
VD.validateNames("FIRST",(*start)->firstname);
VD.validateLWI((*start)->lwi);
VD.validateGrade((*start)->grade);
VD.validateTANF((*start)->tanf);
VD.validateSSN((*start)->ssn);
(*start)->sortvalue = (*start)->corp +
(*start)->lastname +
(*start)->firstname +
(*start)->grade +
(*start)->ssn;
++start;
}
else
{
start = schoolvector.erase(start);
}
}
std::sort( schoolvector.begin(), schoolvector.end() );