CLEANUP: Refactoring of sorting extension.