First time here? Check out the FAQ!
answered 2016-08-08 17:22:02 +0100
You can modify X before printing it, sorting it (as you suggested) and then changing the brackets:
X
s = str(sorted(X)) s = s.replace('[', '\\{') s = s.replace(']', '\\}')
Then print s using
s
\sagestr{s}