Don't close and reopen stream when sorting.

This is a fixup of 00fc944 Change tpie::sort to using tpie::merge_sorter from pipelining.
Add a bunch of documentation.