Refactor sorter