Add sorted take optimizations

closes #880

Should be good enough, I think.
Maybe we should avoid using terms like sortedTake in comments to reduce confusions. Just say we're doing in-memory heap-sort on mappers?