Correcting sort functionality.