refactor(sort): existence of comparator is checked for in sort function