bubble sort vector
I can't seem to figure out to sort this problem.
I've load up a bunch of actors and presidents into a vector call people.
1732 2 22 1789 4 30 George Washington
Actor John Cusack 1966 6 28 2012
Now what I'm trying to do is sort the vector by the date of birth. On the president's data there are 2 dates. One of them is the date of birth and the other is their term start. Both class are a subclass of person. I store the date as a date object to the vector.
So, how do I compare the birthday from the vector?
for(int i = 0; i < people.size();i++)
for(int j = i+1; j < people.size(); j++)
if(people[i] > people[j])
Originally Posted by yes2
Or something like that. Have you overloaded '>' operator for the date object?
if(people[i].date > people[j].date)