code: def write_separated_lines(path, values, separator=' ', sort_by_column=0):
      f = open(path, 'w', encoding='utf-8')
      if type(values) is dict:
          if sort_by_column in [0, 1]:
              items = sorted(values.items(), key=lambda t: t[sort_by_column])
          else:
              items = values.items()
          for key, value in items:
              if type(value) in [list, set]:
                  value = separator.join([str(x) for x in value])
              f.write('{}{}{}\n'.format(key, separator, value))
      elif type(values) is list or type(values) is set:
          if 0 <= sort_by_column < len(values):
              items = sorted(values)
          else:
              items = values
          for record in items:
              str_values = [str(value) for value in record]
              f.write('{}\n'.format(separator.join(str_values)))
      f.close()