i'm trying to sort the linked list by modifying the links not swapping the data.i'm using selection sort.i don't know where i am going wrong.i'm beginner please help me.
struct node
{
int data;
node* link;
};
node* p;
void sort()
{
node* temp = p;
node* save;
node* prev;
node* tprev;
node* push = new node;
tprev = NULL;
for (; temp != NULL; temp = temp->link)
{
push = temp->link;
for (; push != NULL; push = push->link)
{
if (push->data<temp->data)
{
save->link = temp->link;
temp->link = push->link;
push->link = save->link;
prev->link = temp;
tprev->link = push;
}
prev = push;
}
tprev = temp;
}
}