Ask Your Question

Revision history [back]

You can modify X before printing it, sorting it (as you suggested) and then changing the brackets:

s = str(sorted(X))
s = s.replace('[', '\\{')
s = s.replace(']', '\\}')

Then print s using

\sagestr{s}