Improve sort performance