input: Write a python function to sort a dictionary by keys and print it in a formatted way.
  assert sort_and_format_dict({"a": 3, "b": 1, "c": 2}) == '{\n    "a": 3,\n    "b": 1,\n    "c": 2\n}'
  assert sort_and_format_dict({"z": 10, "y": 5, "x": 2}) == '{\n    "x": 2,\n    "y": 5,\n    "z": 10\n}'
  assert sort_and_format_dict({"banana": 1, "apple": 2, "cherry": 3}) == '{\n    "apple": 2,\n    "banana": 1,\n    "cherry": 3\n}'
output: def sort_and_format_dict(d):
      sorted_dict = dict(sorted(d.items()))
      formatted_str = "{\n"
      for key, value in sorted_dict.items():
          formatted_str += f'    "{key}": {value},\n'
      formatted_str = formatted_str.rstrip(",\n") + "\n}"
      return formatted_str