SERVER-10026 fix memory leak in sorting