title: Linked list issue with multiple parameters
body: <p>So I am trying to sort nodes according to their location (an integer) and then by the date (year and month). When I use my overloaded operator to print my linked list, it shows that the list is only inserting one of the wanted nodes meaning that my insert function is not correct. It is not giving any errors, it is just not running as expected. My insert function is below. Does anyone have any ideas as to what is wrong?</p>
  
  <pre><code>void LinkedList::insert(int location, int year, int month, double temperature) {
  // Implement this function
  Node* newNode = new Node();
  newNode-&gt;loc = location;
  newNode-&gt;yr = year;
  newNode-&gt;mo = month;
  newNode-&gt;temp = temperature;
  Node* tempNode = head;
  Node* previousNode = nullptr;
  
  if(tail == nullptr &amp; head == nullptr){
      head = newNode;
  }
  while(tempNode != nullptr){
      if((tempNode-&gt;loc == newNode-&gt;loc) &amp;&amp; (tempNode-&gt;yr == newNode-&gt;yr)){
          if(tempNode-&gt;mo &gt; newNode-&gt;mo){
              newNode-&gt;next = tempNode-&gt;next;
              tempNode-&gt;next = newNode;
          }
          if(tempNode-&gt;mo &lt; newNode-&gt;mo){
              newNode-&gt;next = tempNode;
          }
      }
      if(tempNode-&gt;loc &gt; newNode-&gt;loc){
          newNode-&gt;next = tempNode-&gt;next;
          tempNode-&gt;next = newNode;
      }
      if(tempNode-&gt;loc &lt; newNode-&gt;loc){
          newNode-&gt;next = tempNode-&gt;next;
          tempNode-&gt;next = newNode;
      }
      tempNode = tempNode-&gt;next;
  }
  </code></pre>
  
  <p>}</p>