@classmethod<EOL><INDENT>def resolve(cls, accept, available_renderers):<DEDENT>
assert isinstance(available_renderers, tuple)<EOL>accept = sorted(accept)<EOL>renderers, seen = [], set()<EOL>accept_groups = [[accept.pop()]]<EOL>for imt in accept:<EOL><INDENT>if imt.equivalent(accept_groups[-<NUM_LIT:1>][<NUM_LIT:0>]):<EOL><INDENT>accept_groups[-<NUM_LIT:1>].append(imt)<EOL><DEDENT>else:<EOL><INDENT>accept_groups.append([imt])<EOL><DEDENT><DEDENT>for accept_group in accept_groups:<EOL><INDENT>for renderer in available_renderers:<EOL><INDENT>if renderer in seen:<EOL><INDENT>continue<EOL><DEDENT>for mimetype in renderer.mimetypes:<EOL><INDENT>for imt in accept_group:<EOL><INDENT>if mimetype.provides(imt):<EOL><INDENT>renderers.append(renderer)<EOL>seen.add(renderer)<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return renderers<EOL>
Resolves a list of accepted MediaTypes and available renderers to the preferred renderer.

Call as MediaType.resolve([MediaType], [renderer]).