Sorting vector(BubbleSort)

I have class Date, functions bubbleSort and printVector. So my task is: Use the function bubbleSort to sort vector type objects Date. I've done something but it doesn't works, so can anyone help me with this?
Function bubble sort(doesn't works with "Date", works fine with integers ,strings...):
1
2
3
4
5
6
7
8
9
template<typename T>
void bubbleSort(vector<T> &vec) {
    bool swapp = true;
    while (swapp) {
        swapp = false;
        for (unsigned int i = 0; i < vec.size() - 1; i++) {
            if (vec[i] > vec[i + 1]) {
                swap(vec[i], vec[i + 1]);
                swapp= true;

In main program i tried to do this:
1
2
3
4
5
6
7
     Date date(15,3,1980);
     Date date1(13,6,2010);
     vector <Date> dates;
     dates.push_back(date);
     dates.push_back(date1);
    bubbleSort(dates);
    printVector(dates);
So can we see the < and > operators that you have defined for Date, please.
Last edited on
Topic archived. No new replies allowed.