This looks like just tossing everything into a bag. It would be nice to have `_new_sort` and `_new_partition` (or equivalent) as separate functions, then perhaps factor out the common bit. Eventually the `_new` stuff should probably go away. That whole section of code needs a fixup.