human
Solve in Python:
Linked Lists - Sorted Insert

Write a SortedInsert() function which inserts a node into the correct location of a pre-sorted linked list which is sorted in ascending order. SortedInsert takes the head of a linked list and data used to create a node as arguments. SortedInsert() should also return the head of the list.

The push() and buildOneTwoThree() functions do not need to be redefined.

What is a the Python code you requested?
assistant
#Here is the Python code you requested.

""" For your information:
class Node(object):
    def __init__(self, data):
        self.data = data
        self.next = None
"""

def sorted_insert(head, data):
    if not head:
        return Node(data)
    elif head.data>data:
        res=Node(data)
        res.next=head
        return res
    else:
        temp=head
        while head.next and head.next.data<data:
            head=head.next
        res=Node(data)
        res.next=head.next
        head.next=res
        return temp
        return temp