Refactor sort, calculated laziness