from typing import Set
from typing import Union
from typing import List


def canonicalize_resources(resources: Set[str]) -> Union[str, List[str]]:
    """Return the set of resources as either a single string or a sorted list of strings."""

    if len(resources) == 1:
        return next(iter(resources))

    return sorted(resources)