import typing


def _encode_default(obj: typing.Any) -> typing.Any:
    """
    'default' callback for json.encode,
    encodes set() as a sorted list
    """
    if isinstance(obj, set):
        return sorted(obj, key=lambda v: (type(v).__name__, v))
    elif isinstance(obj, bytes):
        return obj.decode()
    raise TypeError(obj)