def filter_sorted_apps(admin_apps, request):
    """
    Filter admin_apps to show the ones in ``DASHBOARD_SORTED_APPS`` first,
    and remove them from the subsequent listings.
    """

    sorted_apps = []

    for orig_app_spec in appsettings.DASHBOARD_SORTED_APPS:
        # make a copy that we can write to, to fix deprecations without
        # changing settings
        app_spec = orig_app_spec.copy()
        # lookup the models from the names
        app_spec['models'] = _build_app_models(
            request, admin_apps, app_spec['models'], ensure_all_models=True
        )
        # Only add the panel if at least one model is listed.
        if app_spec['models']:
            sorted_apps.append(app_spec)

    used_models = []
    for app in sorted_apps:
        used_models += app['models']

    sorted_apps += _remove_app_models(admin_apps, used_models)

    return sorted_apps
Filter admin_apps to show the ones in ``DASHBOARD_SORTED_APPS`` first,
    and remove them from the subsequent listings.