//-----------------
Sort nodes in
ascending order according to salary --------------------
void Employee::sort( )
{
current = first;
while(current != NULL)
{
EmployeeNode* temp = current->next;
while(temp != NULL)
{
if(current->salary
> temp->salary)
{
EmployeeNode* swaper = new EmployeeNode;
swaper->salary = temp->salary; strcpy_s(swaper->name , temp->name);
temp->salary = current->salary; strcpy_s(temp->name , current->name);
current->salary = swaper->salary; strcpy_s(current->name,swaper->name);
delete swaper;
}
temp = temp->next;
}
delete temp;
current = current->next;
}
}
0 comments: