code: def _write_nmlgrp(self, grp_name, grp_vars, nml_file, sort=False):
          
          if self._newline:
              print(file=nml_file)
          self._newline = True
  
          if self.uppercase:
              grp_name = grp_name.upper()
  
          if sort:
              grp_vars = Namelist(sorted(grp_vars.items(), key=lambda t: t[0]))
  
          print('&{0}'.format(grp_name), file=nml_file)
  
          for v_name, v_val in grp_vars.items():
  
              v_start = grp_vars.start_index.get(v_name, None)
  
              for v_str in self._var_strings(v_name, v_val, v_start=v_start):
                  nml_line = self.indent + '{0}'.format(v_str)
                  print(nml_line, file=nml_file)
  
          print('/', file=nml_file)
docs: Write namelist group to target file.