def dict_to_tuple_key(dictionary):
 return tuple(sorted(dictionary.items()))

def dict_to_tuple_key ( dictionary ) : return tuple ( sorted ( dictionary . items ( ) ) )
converts a dictionary to a tuple that can be used as an immutable key .