from typing import Dict
from typing import Any
from typing import Tuple


def _as_ordered_key(
    dictionary: Dict[str, Any]
) -> Tuple[Tuple[Any, ...], Tuple[Any, ...]]:
    """Turns a dictionary into a tuple. Used at _generate_key.

    First entry is a tuple containing the key, second entry is tuple containing the
    values. Required to create a hashable object of the type-hints of a function,
    that can used for a dictionary key.

    Args:
        dictionary (Dict[Any, Any]): Some dictionary.

    Returns:
        Tuple[tuple, tuple]: The tuple.

    Example:
        >>> hints = {"a": 1, "b": 2}
        >>> assert _as_ordered_key(hints) == (('a', 'b'), (1, 2))
    """
    keys = tuple(key for key in dictionary.keys())
    values = tuple(value for value in dictionary.values())
    return (keys, values)