Preserving results sort after recreate

When an cursor is recreated and wrapped, the sort data is lost. I have
preserved the sort during the wrap so that it is preserved. I have added
a unit test for this issue, and a more general sorting unit test.