Improved sorting methods.