def str_dict(d: dict):
    """
    >>> str_dict({1: 1, "1": "1"})
    "{'1': '1', 1: 1}"
    >>> str_dict({(2, 3): "1", 1: "2", 2: "3", "a": "4", "b": {"1": 1}})
    "{'a': '4', 'b': {'1': 1}, (2, 3): '1', 1: '2', 2: '3'}"
    """
    def to_str(x):
        if isinstance(x, str):
            return "'" + x + "'"
        else:
            return str(x)

    result = "{"
    for i, key in enumerate(sorted(d.keys(), key=to_str)):
        value = d[key]

        if isinstance(value, dict):
            value = str_dict(value)
        else:
            value = to_str(value)

        if i > 0:
            result += ", "
        result += "{}: {}".format(to_str(key), value)
    return result + "}"