# Path: momo/plugins/flask/filters.py
# def get_attr(node, attrname, default=None):
#     """Get content of a node's attr. If attr is not present, return default."""
#     if attrname in node.attrs:
#         return node.attrs[attrname].content
#     return default
# 
# Path: momo/plugins/flask/utils.py
# def str_to_bool(s):
#     if re.match(FALSE_STR_PATTREN, s):
#         return False
#     return True


from momo.plugins.flask.filters import get_attr
from momo.plugins.flask.utils import str_to_bool
    3. Apply sorting nodes in-place with the combined lambda function.
    """
    funcs = parse_sorting_terms(terms, functions)
    sort_nodes(nodes, lambda node: [func(node) for func in funcs], desc)
    return nodes


def sort_nodes(nodes, func, desc=False):
    """
    Sort nodes in-place.

    :param nodes: list of nodes.
    :param func: a function that returns an item as sorting key.
    :param desc: whether in descending order.
    """
    nodes.sort(key=func, reverse=desc)
    return nodes


def parse_sorting_terms(terms, functions):
    """
    Parse a list of sorting terms into a list of sorting key functions.

    :param terms: a list of sorting terms.
    :param functions: a dictionary of sorting key functions.
    """
    res = []
    for term in terms:
        prefix, name = term.split('.')
        if prefix == 'a':

# Path: momo/plugins/flask/filters.py
# def get_attr(node, attrname, default=None):
#     """Get content of a node's attr. If attr is not present, return default."""
#     if attrname in node.attrs:
#         return node.attrs[attrname].content
#     return default
# 
# Path: momo/plugins/flask/utils.py
# def str_to_bool(s):
#     if re.match(FALSE_STR_PATTREN, s):
#         return False
#     return True


# Path: momo/plugins/flask/sorting.py
from momo.plugins.flask.filters import get_attr
from momo.plugins.flask.utils import str_to_bool

    3. Apply sorting nodes in-place with the combined lambda function.
    """
    funcs = parse_sorting_terms(terms, functions)
    sort_nodes(nodes, lambda node: [func(node) for func in funcs], desc)
    return nodes


def sort_nodes(nodes, func, desc=False):
    """
    Sort nodes in-place.

    :param nodes: list of nodes.
    :param func: a function that returns an item as sorting key.
    :param desc: whether in descending order.
    """
    nodes.sort(key=func, reverse=desc)
    return nodes


def parse_sorting_terms(terms, functions):
    """
    Parse a list of sorting terms into a list of sorting key functions.

    :param terms: a list of sorting terms.
    :param functions: a dictionary of sorting key functions.
    """
    res = []
    for term in terms:
        prefix, name = term.split('.')
        if prefix == 'a':

            res.append(lambda node, name=name: get_attr(node, name))