Jak wstawić do posortowanej listy powiązanej? [duplikować]

Możliwy duplikat:
LinkedList „jump jump”

Po prostu muszę mieć połączoną listę w kolejności według nazwy. Mogę go tylko dostać do węzłów 1, 3, 5, .. Po prostu nie mogę tak myśleć. Chcę być programistą C ++, ale jeśli nie rozumiem, to ich nadzieja? Kontenery STLstd::lists nie są dla mnie opcją w tym momencie jako student. To, co widzisz w funkcji listy, jest tym, czego próbuję zrozumieć.

list::node::node(const winery &winery) : item( winery.getName(), winery.getLocation(),
    winery.getAcres(), winery.getRating() ), nextByName( NULL ), nextByRating( NULL )
{

}

void list::insert(const winery& winery)
{
    node *current_node  = new node( winery ); // but came here and did this so it has new info!
    node *next_node     = NULL;
    node *tail_node     = current_node;

    if ( headByName == NULL ) // then we are here for the first item
    {       
        headByName   = current_node; // the list ptrs will have the first node's address. 
        headByRating = current_node; 
    }
    while ( headByName->nextByName != NULL )
    {
        headByName->nextByName = tail_node;
        tail_node = next_node;
        //next_node = current_node;
    }
    tail_node = new node( winery ); 
    headByName->nextByName = tail_node;
}

I wskaźniki, które są dla mnie dostępne:

struct node
{
    winery  item;
    node *  nextByName;
    node *  nextByRating;
};

class list
{
    ...
private:
    node * headByName;
    node * headByRating;
};

questionAnswers(4)

yourAnswerToTheQuestion