I have a struct of data, for example:
struct Data
{
string firstname;
string lastname:
string age;
}
I've placed every struct within one vector (VectorOfData). Is it possible to loop through this vector and sort each struct in the vector by descending age? using something like:
for(std::vector<Data>::const_iterator it = VectorOfData.begin(); it != VectorOfData.end(); ++it)
{
//sorting by age here?
}
I'm assuming it wouldnt be that simple because the it iterator is only accessing one struct within the vector at a time?
I realize i could probably do the sorting before i even put the structs in the vector, but my problem isn't that simple. This is just the simplest way i could explain it. Any advice would be much appreciated, thanks