Made sorting recursive