refactor sort expression function
refactor external sort
refactor