can someone explain me how it does not swap my nodes?

void Library::sortList()
{

    book *head = NULL;
    book *current = head;
    book *newBook;
    current = head;
    ifstream infile;
    infile.open("LibraryData.txt");


    if (infile.is_open())
    {
        while (!infile.eof())
        {
            newBook = new book;

            infile.ignore(100,'#');
            getline(infile,newBook->ISBN);
            infile.ignore(100,'#');
            getline(infile, newBook->author);
            infile.ignore(100,'#');
            getline(infile, newBook->title);
            infile.ignore(100,'#');
            getline(infile, newBook->publisher);
            infile.ignore(100,'#');
            getline(infile, newBook->cpyryt);
            infile >> newBook->quantity;
            infile >> newBook->qborrowed;

            newBook->link = NULL;

            if (head == NULL)
            {
                head = newBook;
                current = newBook;
            }
            else
            {
                current->link = newBook;
                current = newBook;
            }               
        }
    }
    infile.close();
    book *p,*q = current->link;
    current=head;
    while(current->link->link!=NULL)
    {
        if(current->link > current->link->link)
        {
            p = current;
            current = q;
            q = p;
        }
        current = current->link;
    };
    current =head;
    while (current != NULL)
    {
        cout << setw(20) << current->ISBN << "\t" << current->title << endl;
        cout << "\t\t\t" << current->author << endl;
        cout << "\t\t\t" << current->publisher << endl;
        cout << "\t\t\t" << current->cpyryt << endl;
        if(current->quantity==0 && current->qborrowed==1)
            cout<<"\n\t\t\tStatus: BORROWED"<<endl;
        else if(current->quantity==0 && current->qborrowed==0)
            cout<<"\n\t\t\tStatus: REMOVED"<<endl;      
        else if(current->quantity==1 && current->qborrowed==0)
            cout<<"\n\t\t\tStatus: AVAILABLE"<<endl;
        cout << "\n--------------------------------------------------------------------------------" << endl;
        current = current->link;
    }
};

if i change

        if(current->link > current->link->link)

into

         if(current->author > current->link->author)

it does not run display where if it swaps or not and stays into a blank console

post the link structure

how do i post the link structure?

The same way you did the code. Probably need to post class book.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.