samedi 19 août 2017

Sorting link list with string as data member

I'm trying to apply insertion sort on a link list whose data member is string.I don't know whether I use conditional operator with string or not. No output in this case.

void sorting(node &start){
    node *ptr=start.next;
    cout<<endl;
    while(ptr){
       node *ptr1=ptr->next->next;
       while(ptr1){
        if(ptr->key>ptr1->key){
            node *temp=NULL;
            temp->key=ptr->key;
            ptr->key=ptr1->key;
            ptr->key=temp->key;
        }
        ptr1=ptr1->next;
       }
       ptr=ptr->next;
    }
}

Aucun commentaire:

Enregistrer un commentaire