optimize general sorted(x) calls