# 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
# sorting and sorting key functions



class SortingError(Exception):
    pass


def sort_nodes_by_request(nodes, request, g, default_terms=None):
    """High-level function to sort nodes with a request object."""
    sorting_terms = request.args.getlist('sort') or default_terms

# 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

# sorting and sorting key functions



class SortingError(Exception):
    pass


def sort_nodes_by_request(nodes, request, g, default_terms=None):
    """High-level function to sort nodes with a request object."""
    sorting_terms = request.args.getlist('sort') or default_terms

    desc = request.args.get('desc', default=False, type=str_to_bool)