import collections


def sort_dict(source_dict):
  """Recursive alphabetical sort a nested dict.

  Sorts a direct dict child, as well list of dicts.

  Args:
    source_dict: Nested dict

  Returns:
    OrderedDict: Sorted alphabetically by key name.
  """
  sorted_dict = collections.OrderedDict()
  # Alphabetical sort on key.
  for key, val in sorted(source_dict.items(), key=lambda t: t[0]):
    if isinstance(val, dict):
      sorted_dict[key] = sort_dict(val)  # Create new OrderedDict

    elif isinstance(val, list):
      # Sort any child dicts, otherwise skip.
      lst = []
      for item in val:
        if isinstance(item, dict):
          item = sort_dict(item)
        lst.append(item)
      sorted_dict[key] = lst

    else:
      sorted_dict[key] = val

  return sorted_dict