Fixed errors and abstracted sort algorithms.
Finished changes on Laptop