vergesort icon indicating copy to clipboard operation
vergesort copied to clipboard

Stable vergesort

Open Morwenn opened this issue 7 years ago • 1 comments

Theoretically, vergesort could be made stable by only looking for non-decreasing and strictly decreasing runs and using a stable sorting algorithm as a fallback instead of the current quicksort/pdqsort (this runs detection scheme is actually used by timsort to ensure the stability of the algorithm). Such a design decision would also somewhat solve the plateau problems described in #7, but would give suboptimal performance for a non-ascending sequence where one element in two compares equivalent to the previous one.

Morwenn avatar Jun 18 '18 13:06 Morwenn

This standalone project is not the best vessel to host the stable version of vergesort, so I went and implemented it in cpp-sort instead, as a specialization of stable_adapter. It uses uses the trick described here two years ago to achieve stability.

This standalone project does need some README refactor and documentation improvement though, I'm keeping this issue open until it's done.

Morwenn avatar Dec 22 '20 11:12 Morwenn