Index2Sort: Sorting Algorithm Using Static Index Data Structure

Atsuki Sato, Yusuke MatsuiOpenReview 2026 · Submission to ICLR 2026 · Rejected

TL;DR

Index2Sort is a novel framework that transforms any static index data structure (like B-trees or learned indexes) into a sorting algorithm by treating the index as a "black box." By leveraging state-of-the-art learned indexes, the authors achieve a theoretical $O(n)$ expected sorting time, effectively bridging the gap between indexing and sorting research.

What Problem Does This Paper Address?

In the world of algorithm design, indexing and sorting are two sides of the same coin. Traditionally, static indexes—data structures that allow for fast lookups but don't support insertions—require a sorted array to be built in the first place. This creates a "circular dependency": you need to sort data to build an index, so how could you possibly use a static index to sort data?

While "learned indexes" (which use machine learning to predict data locations) have recently achieved $O(1)$ query times, "learned sorts" have lagged behind, stuck at $O(n \log \log n)$ complexity. Researchers previously had to painstakingly redesign the internal guts of an index to create a corresponding sorting algorithm. Index2Sort aims to break this cycle by providing a general framework that uses static indexes as opaque boxes to perform sorting, allowing any advancement in indexing to immediately translate into an advancement in sorting.

Methods

The core of the paper is the Index2Sort algorithm, a recursive approach that uses a "divide, index, and bucket" strategy:

  1. Split: The input array $x$ is split into two parts, $u$ and $v$.
  2. Recurse: The algorithm recursively calls itself to sort $u$, resulting in a sorted array $u'$.
  3. Index Construction: A static index is built using the sorted array $u'$. Because $u'$ is already sorted, the "circular dependency" is avoided.
  4. Rank Query: For every element in the remaining unsorted part $v$, the algorithm queries the index to find its rank (position) relative to the elements in $u'$.
  5. Bucket Sort: Based on these ranks, elements of $v$ are placed into buckets. The authors use two types: range buckets (for values falling between index keys) and point buckets (for values exactly matching index keys). Range buckets are then sorted using a standard algorithm like MergeSort.
  6. Merge: Finally, $u'$ and the now-sorted $v$ are merged to produce the final sorted array.

The framework is "opaque-box," meaning it only requires the index to support two operations: construction and rank queries. It even includes modifications to handle indexes that only provide approximate ranks, using exponential search to refine the results.

Datasets

The authors validated their framework using a wide array of synthetic and real-world datasets:

  • Synthetic: Uniform, Normal, Exponential, and Log-normal distributions, including versions with "distribution shift" (where the mean changes over time).
  • Real-World:
    • Wiki: Timestamps of Wikipedia edits.
  • OSM: OpenStreetMap locations (Google S2 CellIds).
  • Chicago & NYC Taxi: Trip start times, distances, and total fares.
  • SOF: Air quality sensor measurements (humidity, pressure, temperature).
  • Stocks: Historical NASDAQ trading data.
  • Face: Facebook user IDs.

Key Insights and Ideas

  • Inheritance of Guarantees: The most powerful insight is that Index2Sort automatically inherits the complexity of the underlying index. If an index has construction time $O(nC(n))$ and query time $O(Q(n))$, Index2Sort sorts in $O(nC(n) + nQ(n))$.
  • The $O(n)$ Breakthrough: By plugging in the state-of-the-art ESPC Index, which offers $O(1)$ queries under certain distributional assumptions, Index2Sort achieves $O(n)$ expected sorting time. This is a tighter theoretical bound than any previous learned sorting algorithm.
  • Point Buckets Matter: The inclusion of "point buckets" is a subtle but vital detail. It ensures that even if an array has many duplicate elements (which usually breaks bucket-based sorts), the algorithm maintains its linear complexity.
  • Future-Proofing: Because the index is treated as a black box, the sorting community no longer needs to invent new "Learned Sorts" from scratch. They can simply wait for the indexing community to release a faster static index and plug it in.

Key Results

  • Theoretical Dominance: The paper proves that Index2Sort matches or beats the complexity of existing learned sorts. For example, using the RDA index yields $O(n \log \log n)$, matching previous specialized work but with a much simpler, structure-agnostic proof.
  • Empirical Validation: Experiments confirmed that the number of comparisons grows linearly with $n$ across various distributions and index types.
  • Robustness to Real-World Data: On the "SOF" dataset, which features heavy distribution shifts, older learned sorts (like Learned Sort 2.0) degraded to $O(n^2)$ performance, taking over 100 seconds. In contrast, the ESPC-based Index2Sort completed the task in just 0.023 seconds.

Limitations and Future Work

  • The Theory-Practice Gap: While Index2Sort has superior asymptotic complexity (the "Big O"), it is currently slower in raw wall-clock time than highly optimized, hardware-conscious comparison sorters like IS4o. The authors note that their implementation lacks low-level cache optimizations.
  • Worst-Case Complexity: The expected time is great, but the worst-case complexity still relies on the bucket-sorting algorithm used in step 5 (typically $O(n \log n)$).
  • Sort2Index: The authors propose a reverse question for future work: Can we build a framework that derives new indexing structures from existing sorting algorithms?

Reference: Index2Sort: Sorting Algorithm Using Static Index Data Structure. Anonymous Authors. Under review as a conference paper at ICLR 2026.

Summary updated

BibTeX
@misc{sato2026index,
  author = {Atsuki Sato and Yusuke Matsui},
  title = {{Index2Sort: Sorting Algorithm Using Static Index Data Structure}},
  year = {2026},
  url = {https://openreview.net/forum?id=C9GJos8xtd},
  howpublished = {OpenReview},
  note = {Submitted to ICLR 2026},
}
Figure