title: Partition LinkedList out of order Python
body: <p>For some reason my function to partition a linkedlist return everything partitioned except one node. It only happens when that node data is greater than the pivot number. When it's less it falls right in place. What the heck could be happening? Full code ( with LinkedList and Node classes) below.</p>
  <pre><code>class Node():
      def __init__(self,data):
          self.data = data
          self.next = None
          
  
  class LinkedList():
      def __init__(self):
          self.head = None
          self.tail = None
  
      def printing(self):
          tempPrint = self.head
          while tempPrint.next is not None:
              print(tempPrint.data)
              tempPrint = tempPrint.next
          print(tempPrint.data)    
  
      def partition(self, x):
          curr = self.tail = self.head
         
          
          while curr != None:
              temp = curr.next
              #curr.next = None
              if curr.data &lt; x:
                  curr.next = self.head
                  self.head = curr
              else:
                  self.tail.next = curr
                  self.tail = curr
              curr = temp
          
          self.tail.next = None
          
          
              
  node = LinkedList()
  node.head = Node(1)
  n1 = node.head
  n2 = Node(3)
  n3 = Node(2)
  n4 = Node(9)
  n5 = Node(5)
  n6 = Node(1)
  n7 = Node(7)
  n8 = Node(6)
  n1.next = n2
  n2.next = n3
  n3.next = n4
  n4.next = n5
  n5.next = n6
  n6.next = n7
  n7.next = n8
  
  
  node.partition(5)
  node.printing()
  </code></pre>
  <p>output = 1 2 3 1 9 5 7 6 ( pivot was 5 )</p>