# Revision history [back]

One way would be to define a function like this:

def S(i, j, k, l):
return SR.var('S_{}_{}_{}_{}'.format(*(sorted([i, j]) + sorted([k, l]))))


which would return the variables in the order you want.

sage: S(3, 4, 8, 1)
S_3_4_1_8
sage: S(4, 3, 8, 1)
S_3_4_1_8
sage: S(3, 4, 1, 8)
S_3_4_1_8
sage: S(4, 3, 1, 8)
S_3_4_1_8