def _edit_string_for_tags(tags):
 names = []
 for tag in tags:
  name = tag.name
  if ((u',' in name) or (u' ' in name)):
   names.append((u'"%s"' % name))
  else:
   names.append(name)
 return u', '.join(sorted(names))

def _edit_string_for_tags ( tags ) : names = [ ] for tag in tags : name = tag . name if ( ( u',' in name ) or ( u' ' in name ) ) : names . append ( ( u'"%s"' % name ) ) else : names . append ( name ) return u', ' . join ( sorted ( names ) )
given list of tag instances .