hr/sorting problem and cormen/ refactoring