Refactor sort buttons