title: C++ Bubble sorting a Doubly Linked List
body: <p>I know bubble sort is probably not the fastest way to do this but its acceptable. i'm just having trouble with adjusting the algorithm to double link lists from arrays.</p>
  
  <p>My double linked lists have a type int and a type string to hold a number and a word. My list was sorted with an insertion sort that I wrote to sort alphabetically, now I need to reorder my double linked list numerically, greatest to least.</p>
  
  <p>My trouble spot is how to run this loop so that it is properly sorted thoroughly and not just one time. </p>
  
  <p>here's what i've managed to get down so far:</p>
  
  <pre><code>void DblLinkedList::ReorderListNumeric()
  {
  dummy = new Node();
  temphead = head;
  temp = head-&gt;next;
  
  while(tempTwo-&gt;next != NULL)
  {
      if(temp-&gt;wordCount &lt; tempTwo-&gt;wordCount)
      {               
          dummy-&gt;word = tempTwo-&gt;word;
          dummy-&gt;wordCount = tempTwo-&gt;wordCount;
  
          tempTwo-&gt;word = temp-&gt;word;
          tempTwo-&gt;wordCount = temp-&gt;wordCount;
  
          temp-&gt;word = dummy-&gt;word;
          temp-&gt;wordCount = dummy-&gt;wordCount;
      }
      temp = tempTwo;
      tempTwo = tempTwo-&gt;next;
  }
  }
  </code></pre>