`merge_sorted`: improved documentation, comments, and tests

The new tests check that sorts are stable such that when multiple items have
the same key, their original order is preserved.  An alternative implementation
of `merge_sorted` with a key as discussed in #58 is shown as a comment in the
code, because it may be more understandable to some developers.