from typing import OrderedDict


def specification_values_dict(instance):
    """
    Returns a dictionary suitable for outputting the specification field
    values.
    """
    groups = OrderedDict()
    for field in instance.fields.select_related("field__group"):
        groups.setdefault(field.group, []).append(
            (field.name, field.get_value_display())
        )
    return groups