| 1 | initial version |
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}
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.