@Override
    public MultifactorAuthenticationProvider resolve(final Collection<MultifactorAuthenticationProvider> providers,
                                                     final RegisteredService service,
                                                     final Principal principal) {
        val sorted = new ArrayList<>(providers);
        if (sorted.isEmpty()) {
            throw new IllegalArgumentException("List of candidate multifactor authentication providers is empty");
        }
        AnnotationAwareOrderComparator.sort(sorted);
        return selectMultifactorAuthenticationProvider(service, sorted);
    }
This is {@link RankedMultifactorAuthenticationProviderSelector}
that sorts providers based on their rank and picks the one with
the highest priority.

@author Misagh Moayyed
@since 5.0.0
core/cas-server-core-webflow-mfa-api/src/main/java/org/apereo/cas/web/flow/authentication/RankedMultifactorAuthenticationProviderSelector.java