'Return a sort key.
Examples
>>> from sympy.core import S, I
>>> sorted([S(1)/2, I, -I], key=lambda x: x.sort_key())
[1/2, -I, I]
>>> S("[x, 1/x, 1/x**2, x**2, x**(1/2), x**(1/4), x**(3/2)]")
[x, 1/x, x**(-2), x**2, sqrt(x), x**(1/4), x**(3/2)]
>>> sorted(_, key=lambda x: x.sort_key())
[x**(-2), 1/x, x**(1/4), sqrt(x), x, x**(3/2), x**2]'

@cacheit
def sort_key(self, order=None):

    def inner_key(arg):
        if isinstance(arg, Basic):
            return arg.sort_key(order)
        else:
            return arg
    args = self._sorted_args
    args = (len(args), tuple([inner_key(arg) for arg in args]))
    return (self.class_key(), args, S.One.sort_key(), S.One)
