optimize general sorted(x) calls
Merge pull request #344 from larsmans/sorted

optimize general sorted(x) calls