refactor main sort routine in AdaptiveSort