Made sort generic; made more effective memory usage; parallelized in memory sort; fixed sampling algorithm; covered with tests; refactored;