def METHOD_NAME(groups: GroupList, include: GroupMatchList, exclude: GroupMatchList) -> GroupList:
    """filter and sorts groups"""
    recent = dp.filter_metatlas_objects_to_most_recent(groups, "name")
    post_include = dp.filter_metatlas_objects_by_list(recent, "name", include)
    if include:
        logger.debug(
            "Filtered out %d groups for not matching within include containing: %s",
            len(recent) - len(post_include),
            include,
        )
    post_exclude = dp.remove_metatlas_objects_by_list(post_include, "name", exclude)
    if exclude:
        logger.debug(
            "Filtered out %d groups for matching within exclude containing: %s",
            len(post_include) - len(post_exclude),
            exclude,
        )
    not_empty = sorted(dp.filter_empty_metatlas_objects(post_exclude, "items"), key=lambda x: x.name)
    if include or exclude:
        logger.debug(
            "Filtered out %d groups because no LCMS runs remained in them",
            len(post_exclude) - len(not_empty),
        )
    return not_empty