Hello, I have this sort function that needs to be able to sort both strings and ints in a linked list. While the code I have does compile, It seems like it goes into an infinite loop and does not sort my elements. Can anyone see any problems or give me some advice?

template<typename L>  
  void List<L>::sort()
 {
      Node<L>* pt1;
      Node<L>* minPointer;
      Node<L>* pt2;
      pt1=first;

      while (pt1 !=NULL)  
       pt2=pt1->next;  
       minPointer=pt1;
      
      while (pt2 !=NULL)
      {
          if(pt2->data < minPointer->data)
          minPointer=pt2;
       } 
   
        pt2=pt2->next;   
        swap(minPointer->data, pt1->data);
        pt1=pt1->next;    
    }

Please let me know if any of the other parts of the code are needed.

Thank You

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.