parameters: (linkedlist1, linkedlist2)
return_statement: return result_head
docstring: merge two sorted linked lists
docstring_summary: merge two sorted linked lists
docstring_tokens: merge two sorted linked lists
function: def merge_sorted(linkedlist1, linkedlist2):
      """ merge two sorted linked lists """
      node1_ptr = linkedlist1.head
      node2_ptr = linkedlist2.head
      s_ptr = None
  
      if node1_ptr is None:
          return node2_ptr
  
      if node2_ptr is None:
          return node1_ptr
  
      if node1_ptr.data > node2_ptr.data:
          s_ptr = node2_ptr
          node2_ptr = node2_ptr.next
      else:
          s_ptr = node1_ptr
          node1_ptr = node1_ptr.next
  
      result_head = s_ptr
  
      while node1_ptr and node2_ptr:
          if node1_ptr.data > node2_ptr.data:
              s_ptr.next = node2_ptr
              s_ptr = node2_ptr
              node2_ptr = node2_ptr.next
          else:
              s_ptr.next = node1_ptr
              s_ptr = node1_ptr
              node1_ptr = node1_ptr.next
  
      if node2_ptr is None:
          s_ptr.next = node1_ptr
      elif node1_ptr is None:
          s_ptr.next = node2_ptr
  
      return result_head
function_tokens: def merge_sorted ( linkedlist1 , linkedlist2 ) : node1_ptr = linkedlist1 . head node2_ptr = linkedlist2 . head s_ptr = None if node1_ptr is None : return node2_ptr if node2_ptr is None : return node1_ptr if node1_ptr . data > node2_ptr . data : s_ptr = node2_ptr node2_ptr = node2_ptr . next else : s_ptr = node1_ptr node1_ptr = node1_ptr . next result_head = s_ptr while node1_ptr and node2_ptr : if node1_ptr . data > node2_ptr . data : s_ptr . next = node2_ptr s_ptr = node2_ptr node2_ptr = node2_ptr . next else : s_ptr . next = node1_ptr s_ptr = node1_ptr node1_ptr = node1_ptr . next if node2_ptr is None : s_ptr . next = node1_ptr elif node1_ptr is None : s_ptr . next = node2_ptr return result_head