private static <V> Routed<V> findBest(List<Routed<V>> routes) {
        Routed<V> result = Routed.empty();
        for (Routed<V> route : routes) {
            final RoutingResult routingResult = route.routingResult();
            if (routingResult.isPresent()) {
                //
                // The services are sorted as follows:
                //
                // 1) the service with method and media type negotiation
                //    (consumable and producible)
                // 2) the service with method and producible media type negotiation
                // 3) the service with method and consumable media type negotiation
                // 4) the service with method negotiation
                // 5) the other services (in a registered order)
                //
                // 1) and 2) may produce a score between the lowest and the highest because they should
                // negotiate the produce type with the value of 'Accept' header.
                // 3), 4) and 5) always produces the lowest score.
                //

                // Found the best matching.
                if (routingResult.hasHighestScore()) {
                    result = route;
                    break;
                }

                // We have still a chance to find a better matching.
                if (result.isPresent()) {
                    if (routingResult.score() > result.routingResult().score()) {
                        // Replace the candidate with the new one only if the score is better.
                        // If the score is same, we respect the order of service registration.
                        result = route;
                    }
                } else {
                    // Keep the result as a candidate.
                    result = route;
                }
            }
        }
        return result;
    }
Finds the most suitable service from the given {@link ServiceConfig} list.
core/src/main/java/com/linecorp/armeria/server/Routers.java