Сортировка односвязного списка
void SortByPhone(){
bool run=true;
Student* cur;
Student* pre;
while (run==true){
cur=pFirstStudent;
pre=NULL;
run=false;
while (cur->pNextStudent!=NULL){
if ( (cur->phonenumber) > (cur->pNextStudent->phonenumber) ){
if (pre==NULL){
pFirstStudent=cur->pNextStudent;
cur->pNextStudent=cur->pNextStudent->pNextStudent;
pFirstStudent->pNextStudent=cur;
cout<<"First Change"<
cur->pNextStudent=cur->pNextStudent->pNextStudent;
pre->pNextStudent=cur;
run=true;
cout<<"Non First Change"<
}
}
}
}
Почему не работает? Список без заглавного звена, тупо висит; тестовые выводы тоже не выводятся