nodes: 0, module; 1, function_definition; 2, function_name:write_separated_lines; 3, parameters; 4, block; 5, identifier:path; 6, identifier:values; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, identifier:separator; 14, string; 15, identifier:sort_by_column; 16, integer:0; 17, comment:"""
      Writes list or dict to file line by line. Dict can have list as value then they written
      separated on the line.
  
      Parameters:
          path (str): Path to write file to.
          values (dict, list): A dictionary or a list to write to the file.
          separator (str): Separator to use between columns.
          sort_by_column (int): if >= 0, sorts the list by the given index, if its 0 or 1 and its a
                                dictionary it sorts it by either the key (0) or value (1). By default
                                0, meaning sorted by the first column or the key.
      """; 18, assignment; 19, comparison_operator:type(values) is dict; 20, block; 21, elif_clause; 22, call; 23, string_content:; 24, identifier:f; 25, call; 26, call; 27, identifier:dict; 28, if_statement; 29, for_statement; 30, boolean_operator; 31, block; 32, attribute; 33, argument_list; 34, identifier:open; 35, argument_list; 36, identifier:type; 37, argument_list; 38, comparison_operator:sort_by_column in [0, 1]; 39, block; 40, else_clause; 41, pattern_list; 42, identifier:items; 43, block; 44, comparison_operator:type(values) is list; 45, comparison_operator:type(values) is set; 46, if_statement; 47, for_statement; 48, identifier:f; 49, identifier:close; 50, identifier:path; 51, string; 52, keyword_argument; 53, identifier:values; 54, identifier:sort_by_column; 55, list; 56, expression_statement; 57, block; 58, identifier:key; 59, identifier:value; 60, if_statement; 61, expression_statement; 62, call; 63, identifier:list; 64, call; 65, identifier:set; 66, comparison_operator:0 <= sort_by_column < len(values); 67, block; 68, else_clause; 69, identifier:record; 70, identifier:items; 71, block; 72, string_content:w; 73, identifier:encoding; 74, string; 75, integer:0; 76, integer:1; 77, assignment; 78, expression_statement; 79, comparison_operator:type(value) in [list, set]; 80, block; 81, call; 82, identifier:type; 83, argument_list; 84, identifier:type; 85, argument_list; 86, integer:0; 87, identifier:sort_by_column; 88, call; 89, expression_statement; 90, block; 91, expression_statement; 92, expression_statement; 93, string_content:utf-8; 94, identifier:items; 95, call; 96, assignment; 97, call; 98, list; 99, expression_statement; 100, attribute; 101, argument_list; 102, identifier:values; 103, identifier:values; 104, identifier:len; 105, argument_list; 106, assignment; 107, expression_statement; 108, assignment; 109, call; 110, identifier:sorted; 111, argument_list; 112, identifier:items; 113, call; 114, identifier:type; 115, argument_list; 116, identifier:list; 117, identifier:set; 118, assignment; 119, identifier:f; 120, identifier:write; 121, call; 122, identifier:values; 123, identifier:items; 124, call; 125, assignment; 126, identifier:str_values; 127, list_comprehension; 128, attribute; 129, argument_list; 130, call; 131, keyword_argument; 132, attribute; 133, argument_list; 134, identifier:value; 135, identifier:value; 136, call; 137, attribute; 138, argument_list; 139, identifier:sorted; 140, argument_list; 141, identifier:items; 142, identifier:values; 143, call; 144, for_in_clause; 145, identifier:f; 146, identifier:write; 147, call; 148, attribute; 149, argument_list; 150, identifier:key; 151, lambda; 152, identifier:values; 153, identifier:items; 154, attribute; 155, argument_list; 156, string; 157, identifier:format; 158, identifier:key; 159, identifier:separator; 160, identifier:value; 161, identifier:values; 162, identifier:str; 163, argument_list; 164, identifier:value; 165, identifier:record; 166, attribute; 167, argument_list; 168, identifier:values; 169, identifier:items; 170, lambda_parameters; 171, subscript; 172, identifier:separator; 173, identifier:join; 174, list_comprehension; 175, string_content; 176, identifier:value; 177, string; 178, identifier:format; 179, call; 180, identifier:t; 181, identifier:t; 182, identifier:sort_by_column; 183, call; 184, for_in_clause; 185, escape_sequence:\n; 186, string_content; 187, attribute; 188, argument_list; 189, identifier:str; 190, argument_list; 191, identifier:x; 192, identifier:value; 193, escape_sequence:\n; 194, identifier:separator; 195, identifier:join; 196, identifier:str_values; 197, identifier:x
code: def write_separated_lines(path, values, separator=' ', sort_by_column=0):
      """
      Writes list or dict to file line by line. Dict can have list as value then they written
      separated on the line.
  
      Parameters:
          path (str): Path to write file to.
          values (dict, list): A dictionary or a list to write to the file.
          separator (str): Separator to use between columns.
          sort_by_column (int): if >= 0, sorts the list by the given index, if its 0 or 1 and its a
                                dictionary it sorts it by either the key (0) or value (1). By default
                                0, meaning sorted by the first column or the key.
      """
      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()