Hello,can anybody help me implement the sort() function of a double linked list. The node`s of the list contains objects of type Person:
class Person {
int age;
string name;
string adress;
};
And i want to sort all the Person`s by age.I tried implementing bubble sort,but I dont think i did it good:
void sort()
{
Person* pp;
for(int i = 0; i < (nr - 1); i++)
{
for(int j = 1; j < nr; j++)
{
if(pp[j].getAge() > pp[j + 1].getAge() )
{
Person temp;
temp = pp[j];
pp[j] = pp[j + 1];
pp[j + 1] = temp;
}
}
}
}