Adds sort functionality and fixes search functinality bugs