sorting: code cleanup