def _ll_new_node(name, phone):
    return {'name': name, 'phone': phone, 'next': None}


def ll_insert(head, name, phone):
    node = head
    while node is not None:
        if node['name'] == name:
            node['phone'] = phone
            return head
        node = node['next']

    new_node = _ll_new_node(name, phone)
    new_node['next'] = head
    return new_node


def ll_find(head, name):
    node = head
    while node is not None:
        if node['name'] == name:
            return node['phone']
        node = node['next']
    return None


def ll_delete(head, name):
    if head is None:
        return None

    if head['name'] == name:
        return head['next']

    node = head
    while node['next'] is not None:
        if node['next']['name'] == name:
            node['next'] = node['next']['next']
            return head
        node = node['next']

    return head


def ll_list_all(head):
    records = []
    node = head
    while node is not None:
        records.append((node['name'], node['phone']))
        node = node['next']
    return sorted(records)
