Refactoring. Merged sort methods in PreProcessUtils and CommonTableFunctions.