Implemented sort, refactor needed