SERVER-12438 better handling of batchSize and limit with sort

(cherry picked from commit b9167f0fe82160967e591aefba5824a8a372353d)