def merge_list(self, l1, l2): if l1 and l2: p1, p2 = l1, l2 fakeHead = ListNode(None) cur = fakeHead while p1 and p2: if p1.val <= p2.val: cur.next = p1 p1 = p1.next else: cur.next = p2 p2 = p2.next cur = cur.next cur.next = p1 if p1 else p2 return fakeHead.next return l1 or l2