Implemented barebones sort function