- Code: Select all
node *current = last;
node *current2 = start;
for (int k = count ; k > 1 ; k-- ) {
node *max = new node;
max->value=0;
for (int j=1 ; j <= k ; j++) {
if ( max->value < current2->value )
max = current2;
current2 = current2->next;
}
current2 = start;
node *temp = current;
current = max;
current->next = max->next;
current->prev = max->prev;
max = temp;
max->next = temp->next;
max->prev = temp->prev;
current = temp->prev;
}
but after i print it ... it look same ...
the nodes not changed
i dont know why
can u guys fix this or give me a better algorithm to sort a D LL
