Adaptive Shivers Sort: An Alternative Sorting Algorithm
Vincent Jugé
Abstract
We present a new sorting algorithm, called adaptive ShiversSort, that exploits the existence of monotonic runs for sorting efficiently partially sorted data. This algorithm is a variant of the wellknown algorithm TimSort, which is the sorting algorithm used in standard libraries of programming languages such as Python or Java (for non-primitive types). More precisely, adaptive ShiversSort is a so-called k-aware merge-sort algorithm, a class that was introduced by Buss and Knop that captures "TimSort-like" algorithms.
In this article, we prove that, although adaptive ShiversSort is simple to implement and differs only slightly from TimSort, its computational cost, in number of comparisons performed, is optimal within the class of natural merge-sort algorithms, up to a small additive linear term: this makes adaptive ShiversSort the first k-aware algorithm to benefit from this property, which is also a 33% improvement over TimSort's worst-case. This suggests that adaptive ShiversSort could be a strong contender for being used instead of TimSort.
Then, we investigate the optimality of k-aware algorithms: we give lower and upper bounds on the best approximation factors of such algorithms, compared to optimal stable natural merge-sort algorithms. In particular, we design generalisations of adaptive ShiversSort whose computational costs are optimal up to arbitrarily small multiplicative factors.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext aad52a8c-6207-442c-afee-1785aa9e9852Cited by top-tier papers1
Ask how each one uses itRelated papers
- An Optimal Algorithm for Sorting Pattern-Avoiding SequencesMichal OplerFOCS 2024 · 1 citation
- Parallel Integer Sort: Theory and PracticeXiaojun Dong, Laxman Dhulipala, Yan Gu, Yihan SunPPoPP 2024 · 9 citations
- Sorting Compressed Time SeriesZhiheng Liu, Xingyu Liu, Shaoxu Song, Jianmin WangICDE 2026
- Fast and Simple Sorting Using Partial InformationBernhard Haeupler, Richard Hladík, John Iacono, Václav Rozhon et al.SODA 2025 · 3 citations
- Flexway O-Sort: Enclave-Friendly and Optimal Oblivious SortingTianyao Gu, Yilei Wang, Afonso Tinoco, Bingnan Chen et al.USENIX Security 2025
