Refactor sort algorithms.