Refactored Sort.
Added SortTest