Am I on the rigth track???
I am doing the sorting when inserting a new item. So far I am trying to do it with a "while" and then a nested if. Looks something like this:
Code:
if (temp->nxt == NULL)
{
cout << "List sorted according to age!" << endl;
}
else
{
temp = start_ptr;
while (temp->nxt != NULL)
{
if (temp->age > temp->nxt->age)
{
temp2 = temp->nxt;
temp->nxt = temp;
temp = temp2;
start_ptr = temp;
}
else
cout << "List sorted according to age!" << endl;
}
}
Am I on the rigth track????
Cheers,
Proggy :cool: