def METHOD_NAME(is_lower: bool, adjustment: Weights) -> Callable[[Metric], Any]:
    adjust = asdict(adjustment)
    def key_by(metric: Metric) -> Any:
        tot = sum(
            val / adjust[key] if adjust[key] else 0
            for key, val in asdict(metric.weight).items()
        )
        key = (
            -(metric.comp.always_on_top),
            -(metric.comp.preselect),
            -round(tot * metric.weight_adjust * 10000),
            -len(metric.comp.secondary_edits),
            -(metric.comp.kind != ""),
            -(metric.comp.doc is not None),
            -metric.comp.sort_by[:1].isalnum(),
            strxfrm(
                metric.comp.sort_by.swapcase() if is_lower else metric.comp.sort_by
            ),
        )
        return key
    return key_by