def format_pattrs(pattrs: List['api.PrettyAttribute']) -> str:
    """Generates repr string given a list of pattrs."""
    output = []
    pattrs.sort(
        key=lambda x: (
            _FORMATTER[x.display_group].display_index,
            x.display_group,
            x.name,
        )
    )
    for display_group, grouped_pattrs in groupby(pattrs, lambda x: x.display_group):
        output.append(
            _FORMATTER[display_group].formatter(display_group, grouped_pattrs)
        )

    return '\n'.join(output)
Generates repr string given a list of pattrs.