I'm trying to sort a simple linked list, but I'm not getting it, it only changes the first node because the value is smaller, the rest does not change.
void ordenar(lista **l) {
int tam = tamanho((*l));
lista *prev, *current = (*l)->prox;
for(int i=0; i<tam - 1; i++) {
prev = *l;
for(int j=0; j<tam; j++) {
if(prev->data > current->data) {
troca(prev, current);
}
current = prev->prox;
}
prev = prev->prox;
}
}