Conceptio › Archive › arXiv CS
arXiv CS open access

Efficient Semantic ORDER BY via Transitivity-Aware LLM Batch Sorting

Akinkunle Akintayo Akinola et al. · arxiv_cs
arXiv CS · Papers
Open Source ↗Direct PDF ↓
data-managementdatabasessqlstorage
Large language models (LLMs) enable declarative semantic sorting through LLM-ORDER BY operators that rank tuples according to natural-language criteria over unstructured data. Executing such operators efficiently is challenging because LLM comparisons are expensive, stochastic, and sometimes inconsi
Conceptio Open Archive

Analyze & explore related research in Conceptio

Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.

Efficient Semantic ORDER BY via Transitivity-Aware LLM Batch Sorting Akinkunle Akintayo Akinola

Arijit Khan

arXiv:2611.32073v1 [cs.DB] 24 Nov 2026

Bowling Green State University, USA akinola@bgsu.edu arijitk@bgsu.edu

Abstract—Large language models (LLMs) enable declarative semantic sorting through LLM-ORDER BY operators that rank tuples according to natural-language criteria over unstructured data. Executing such operators efficiently is challenging because LLM comparisons are expensive, stochastic, and sometimes inconsistent. Pairwise approaches require many costly calls. Listwise approaches such as external merge sort rank several items per call, but they follow a fixed merge schedule and keep no record of earlier answers: each merge call re-asks orderings that previous calls have already revealed, directly or by transitivity. We present Transitive Batched Sort (TBS), a transitivity-aware physical operator for semantic sorting that records every revealed preference in a global acyclic preference graph and issues a listwise request only for items whose relative order is not yet implied. To scale, TBS stores only directly observed preferences and answers transitivity queries through a memory-efficient reachability index; to handle noisy LLM outputs, it validates responses and rejects cycle-inducing updates. We evaluate TBS on six benchmarks spanning structured sorting, product price ranking, passage ranking, and personalized recommendation with four LLMs. TBS reduces API calls by 12–20× relative to pairwise quicksort and, at the same batch size, uses 1.1–1.6× fewer calls and 1.3–5.3× lower cost than listwise merge sort while achieving competitive or higher ranking quality across most benchmarks; on Amazon it scales to one million products. These results show that reusing previously inferred preference relations, rather than re-querying them, is an effective foundation for scalable semantic ORDER BY operators. Index Terms—Semantic query processing; LLM-guided sorting; batched LLM inference; transitive closure

I. I NTRODUCTION Declarative Semantic Sorting in Database Engines. Integrating Large Language Models (LLMs) into relational query engines enables declarative querying over unstructured attributes using subjective, natural-language criteria [1], [2]. Unlike supervised learning-to-rank models [3], which require labeled training data, or retrieval pipelines built on precomputed embedding indices [4], [5], an LLM can interpret a new criterion zero-shot at query time. Recent systems expose this capability as semantic operators that extend SQL-style dataflows, including a declarative semantic sorting clause, LLM-ORDER BY, that ranks tuples by a natural-language criterion [1], [2]. While declarative specification simplifies query authoring, executing semantic sorting efficiently is difficult. Classical sort operators [6] assume cheap, deterministic, and transitive comparisons, whereas LLM comparators are expensive, stochastic, and can be inconsistent. Existing LLM-ORDER BY operators [1], [2], [7] reduce cost through access-path

selection or pivot-based schedules, but they lack physical operators that retain and reuse the preferences revealed by earlier LLM calls. Example 1 (Situation report prioritization with implicit urgency): During emergency disaster response, an operations center maintains real-time situation reports in a relational table: SITREP (id, ward, category, reported_at, description), containing hundreds of streaming incident logs. The description attribute contains unstructured text, e.g., “Chest-deep water blocking access road to Riverside Nursing Home”, or “Minor pooling in parking lot; no injuries.” Explicit ORDER BY. An analyst attempting to prioritize severe incidents using standard SQL must engineer brittle, hand-tuned scoring heuristics: SELECT id FROM SITREP ORDER BY 0.15 * recency_score(reported_at) + 0.85 * keyword_hits(description, CRITICAL_TERMS) DESC;

Such explicit scoring functions may fail to capture nuanced domain semantics and require continuous manual retuning as operational conditions change. Even enhancing such heuristics with supervised learning-to-rank models [3] requires labeled training data and task-specific feature engineering that are impractical in rapidly evolving operational workloads. Semantic ORDER BY. In contrast, declarative semantic sorting delegates domain understanding to an LLM via natural language: SELECT id FROM SITREP LLM-ORDER BY "Rank by immediate response urgency, prioritizing life safety, critical-facility access, and vulnerable populations.";

The Physical Execution Bottleneck. While conceptually straightforward, executing LLM-ORDER BY inside a relational query engine violates classical database sorting assumptions [6], which rely on cheap, deterministic, and strictly transitive pairwise comparators to achieve O(n log n) complexity. Generative LLM comparators violate every one of these assumptions: they are expensive (each call incurs monetary API cost and network latency), stochastic (non-deterministic across invocations), and non-transitive (produce cyclic preferences). Existing LLM-augmented sorting approaches [2], [8] exhibit critical limitations:

Costly Pairwise Comparisons: Classic sorting algorithms such as quicksort and merge sort rely on pairwise comparisons [8], [9]. This is acceptable for classical sorting operators [6], where a comparison is nearly free, but with LLMs each comparison is a costly API call that settles a single pair, even though one call can order a larger batch. Comparator cost therefore dominates query latency (e.g., about 1,500 calls for Quicksort at n = 200). • Pointwise Calibration: Pointwise scoring assigns an independent scalar rating to each tuple [8]. It is cheap and accurate when every key has an absolute attribute the model can recall, such as a player’s height. Scores from separate prompts are not calibrated against each other, however, so pointwise degrades on relative criteria such as relevance or preference (§VI-B1). • Redundant Listwise Merge Calls: Listwise prompting amortizes cost by ranking batches of size m [2], [10], [11]. The strongest published listwise LLM-ORDER BY schedule is OrderByLLM external merge sort [2]: it sorts contiguous runs of m keys, then merges those runs with further listwise calls of size up to m (Alg. 4; merge width h=⌊m/2⌋ heads from each run). That schedule never stores the pairwise preferences a call reveals, so a merge batch can re-ask in-run pairs that Round 1 already ordered—even when the merge prompt itself uses the full batch budget m. Figure 1 makes this concrete for m=4 on n=12: after three shared Round 1 calls, merge call 4 ranks {2, 3, 1, 4} and re-queries 2≺3 and 1≺4, which calls 1–2 already returned; seven further merge calls each repeat at least one known in-run pair (11 calls total). Sliding-window rerankers have an analogous issue when overlapping windows re-rank the same keys. Neither family can detect that a later batch is already implied by earlier answers. • Stochastic Noise and Cycle Inconsistencies: LLM outputs frequently exhibit positional bias, missing identifiers, duplicates, and non-transitive preference cycles (A ≻ B ≻ C ≻ A). A practical database engine must enforce strict partialorder consistency over noisy, malformed generative replies. •

Our Approach: Transitive Batched Sort (TBS). To address these challenges, we propose TBS, a transitivity-aware physical operator for semantic sorting. Unlike classical database sort operators [6], which assume cheap and deterministic comparisons, and unlike OrderByLLM merge sort [2], which discards preferences after each call, TBS is built around expensive listwise LLM calls and a persistent preference DAG. It organizes keys into a fixed three-round batch schedule (column sorting, recursive row sorting, and diagonal stitching) whose rounds compare largely disjoint sets of pairs, and records every accepted preference as a DAG edge. Before issuing a scheduled batch, TBS tests reachability and skips the call if every pair in the batch is already implied—the reason the m=4 walk-through in Figure 1 finishes in 7 calls instead of merge’s 11, with Round 2 rows closing the total order by transitivity and no diagonal or packing calls required. Rather than materializing the quadratic transitive closure, TBS

calls 4–7

call 4

call 1

2

1

0

3

4

5

call 1

2

1

0

3

4

5

8

7

6

9

10

11

call 3

8

7

6

9

10

11

call 2

call 3

call 2

(a) Listwise merge sort (11 calls)

(b) TBS (7 calls)

Fig.

1: Walk-through with m=4 on shuffled input X=(8, 9, 3, 2, 10, 4, 7, 1, 0, 11, 6, 5) (ascending gold order 0≺1≺ · · · ≺11). The drawing is the 4×3 grid after Round 1. Shared Round 1 (3 calls). Call 1 sorts {8, 9, 3, 2} to 2≺3≺8≺9; call 2 sorts {10, 4, 7, 1} to 1≺4≺7≺10; call 3 sorts {0, 11, 6, 5} to 0≺5≺6≺11. (a) Listwise merge sort [2] (Alg. 4) then merges the three sorted runs with h=⌊m/2⌋=2 (merge batch size up to m). Call 4 ranks {2, 3, 1, 4} (red box) as 1≺2≺3≺4. The dashed pairs 2≺3 and 1≺4 were already returned by calls 1–2: the size-4 merge re-asks them. Seven further merge calls follow, each likewise repeating at least one already-known in-run pair, for 11 LLM calls total. (b) TBS stores the same Round 1 answers in a DAG. Round 2 here sorts every row, as in Algorithm 2 (the experiments’ default sorts only R0 , §V-A). Round 2 sorts the four rows (calls 4–7): {2, 1, 0}→0≺1≺2, {3, 4, 5}→3≺4≺5, {8, 7, 6}→6≺7≺8, {9, 10, 11}→9≺10≺11 (solid box = call 4; dashed boxes = calls 5–7). Transitivity closes the full chain 0≺1≺ · · · ≺11, so u=0: no diagonal calls and no packing. Total: 7 LLM calls (vs. 11 for merge). stores only direct edges and answers reachability through a dynamic topological-order index (linear memory in keys and stored preferences). To handle noisy LLM outputs, it validates each reply with six checks and rejects cycle-inducing edges; to control cost, it stops early once a target fraction of pairs is ordered and selects m automatically. Our Contributions. We make the following contributions: • Transitivity-Aware Physical Operator: We formalize declarative LLM-ORDER BY and design TBS, a three-round batched schedule that records every listwise answer in a preference graph and skips batches whose pairs are already implied by transitivity, eliminating the re-ask of known pairs that listwise merge sort incurs even at full merge batch size m (Figure 1). Unlike classical k-sorter and grid schedules [12]–[14], which assume a perfect comparator, TBS skips batches already settled by earlier answers and rejects contradictions. Cycle-inducing updates are rejected, so the graph stays acyclic and TBS always returns a total order consistent with all accepted preferences. • Memory-Efficient Reachability Index: We replace explicit transitive closure with a direct-edge DAG and a dynamic topological-order index. The index makes the same decisions as explicit closure while using linear rather than quadratic memory, and in our experiments it is 45–1,200× faster with 25–83× less peak memory (median cachereplay sort time after warm-up; peak Python heap via tracemalloc).

TABLE I: Comparison with selected prior work on LLM-based ranking and semantic ORDER BY. Columns are grouped into scope, state reuse, and robustness and analysis; ✓ means the property is present, – means it is absent or not addressed. Op: targets a database semantic ORDER BY over a supplied key list. ZS: uses zero-shot general-purpose chat models. Full: materializes a global total order. POG: maintains an explicit global graph of accepted preferences across calls. Transitivity: queries that graph for transitively implied relations and skips a call when all its pairs are already implied. Validation: repairs malformed outputs. Batch-size: tunes listwise batch size. Membership: ablates batch record membership and prompt order. Errors: formalizes sorting errors separately from format repair.

Method

ZS

Full

POG

Transitivity

Validation

Batch-size

Membership

Errors

State reuse Robustness / analysis

Op

Scope

OrderByLLM [2] LOTUS [1] ListK [7] LLM-RankFusion [15] LLM rerankers [9], [11], [16] Setwise [17] Trained LTR rerankers [3], [18]

✓ ✓ ✓ – – – –

✓ ✓ – ✓ ✓ ✓ –

✓ ✓ ✓ – – – –

– – – – – – –

– – – – – – –

✓ – – – – – –

– – – – – – –

– – – – – – –

– – – – – – –

TBS (Ours)

✓ ✓ ✓ ✓

✓

✓ ✓ ✓

✓

Robustness, Tuning for Noisy LLMs, and Optimization: We introduce a six-check validation-and-repair layer, cycleinducing update rejection, completion-based early stopping, and knee-based batch-size selection. We also study how Round 1 membership presets affect quality and cost. • Comprehensive Evaluation: On six benchmarks and four LLMs, TBS uses 12–20× fewer API calls than pairwise Quicksort [2] and fewer calls than OrderByLLM listwise merge sort at matched m on every dataset (e.g., 97 vs. 148 on NBA and 1,790 vs. 2,347 on DL19 with GPT-4o), while staying competitive with merge quality and leading mean full-list nDCG on DL19 and SciFact (within 0.008 of QS1 on MovieLens). •

II. R ELATED W ORK This work lies within the emerging area of AI-augmented database systems, where LLMs are integrated into query execution to support semantic operators over unstructured data [1], [2], [7]. We focus on semantic LLM-ORDER BY, which aims to produce a global ranking of a supplied key list according to a natural language criterion. Prior work differs primarily in the interaction paradigm used to obtain rankings from an LLM, including pointwise, pairwise, and listwise approaches. We review these paradigms and discuss their implications for semantic sorting. A. Pointwise, Pairwise, and Listwise Paradigms Classical database sorting assumes a cheap, deterministic, and consistent comparator [6]. LLM-based comparators violate these assumptions because generation is stochastic, outputs may depend on presentation order [19], and APIs typically

return permutations or pairwise preferences rather than calibrated scores [8], [9]. Accordingly, prior work has explored pointwise, pairwise, and listwise ranking paradigms. Dai et al. [8] compare these approaches and show that no single paradigm dominates across tasks. Within database systems, Zhao et al. [2] formalize the LLM-ORDER BY operator and study multiple execution strategies, including pairwise Quicksort (LOTUS [1]) and listwise Merge Sort schedules. These schedules reuse earlier answers only through their fixed structure (pivot partitions or sorted runs); none maintains an explicit global record of the preferences revealed across calls, so relations implied by transitivity across different batches cannot be used to skip later calls. In contrast, our work treats revealed preferences as shared state and exploits transitive inference to reduce redundant LLM calls. TBS further designs its three-round grid so that each round compares largely disjoint sets of pairs, and uses greedy packing to cover the remaining unresolved pairs. ListK [7] studies semantic sorting and top-K selection using fine-tuned listwise rankers such as RankZephyr [20]. Whereas ListK focuses on specialized ranking models and pivotbased recursive schedules, our work targets general-purpose chat models and focuses on the execution of LLM-ORDER BY through preference-graph maintenance, transitivity-aware query skipping, and robustness to inconsistent outputs. SortBench [21] evaluates the ability of LLMs to sort lists across numeric, lexical, and mixed ordering tasks. Our evaluation complements SortBench by studying semantic ordering as a database operator, measuring both ranking quality and execution cost across structured sorting, passage ranking, and recommendation workloads. B. Inconsistency of LLM Orderings LLM-generated rankings are often inconsistent. Wang et al. show that GPT-4 exhibits position bias in pairwise comparisons, leading to unstable preference judgments [19]. Zeng et al. identify transitivity violations in LLM-generated rankings and propose LLM-RankFusion, which improves robustness by aggregating rankings from multiple rankers [15]. These efforts aim to mitigate inconsistency through ranking aggregation and calibration. In contrast, our work treats inconsistency as a systems challenge for semantic sorting operators: detected contradictions are prevented from entering the maintained preference graph, ensuring that the stored ordering remains acyclic even when individual LLM outputs are noisy. C. LLM-Based Ranking and Reranking LLMs are increasingly used as rerankers in retrieval pipelines, where an initial retrieval stage produces a candidate set that is subsequently reordered by an LLM [9], [11], [16]. These approaches primarily optimize top-K relevance and retrieval metrics. Setwise prompting further reduces inference cost by ranking small subsets of candidates at a time [17]. In contrast, we study semantic ORDER BY execution, whose goal is to produce a complete ordering over a relation rather than rerank a fixed set of retrieved documents. Consequently, our

focus is on reducing LLM comparison costs while maintaining a globally consistent ordering across the entire dataset. D. Learning to Rank Learning-to-rank (LTR) methods train ranking functions using labeled relevance judgments or implicit feedback [3], [22]. Classical pointwise, pairwise, and listwise approaches, including LambdaMART and modern cross-encoder architectures, remain highly effective when sufficient training data are available [18], [23]. However, LTR assumes a fixed ranking objective known during training. Semantic ORDER BY queries instead allow users to specify ranking criteria dynamically in natural language. Our goal is therefore not to learn a specialized ranker, but to execute such queries directly using a general-purpose LLM while minimizing comparison costs. E. Positioning of TBS Prior work on LLM-based ranking spans pointwise, pairwise, and listwise prompting, as well as database operators for semantic sorting, each trading ranking quality against inference cost. As Table I shows, systems that return a full order for a supplied key list (OrderByLLM, LOTUS, ListK) do not maintain an explicit global record of the preferences revealed by earlier calls, while methods that address ranking inconsistency or quality (LLM-RankFusion, rerankers, Setwise) do not target a database ORDER BY. Among the LLMbased methods in the table, TBS is the only one that combines a global total order with a maintained preference graph and transitivity-based call skipping. Transitive reuse is established in crowdsourced sorting [24]; our contribution is to make it work for listwise LLM calls at million-key scale. Additional related work is discussed in the Appendix. TBS therefore addresses a complementary execution problem: reusing preferences across listwise calls to avoid redundant LLM evaluations. It records accepted preferences in an acyclic graph, uses reachability to identify resolved comparisons, and stores only direct edges to keep memory low. It also validates malformed replies and rejects cycle-inducing updates, and we study how batch size and batch membership affect quality and cost. Because the graph is built from LLM outputs, the benefit of reuse depends on the accuracy of the accepted preferences, which makes the quality–cost trade-off central to our evaluation. III. P RELIMINARIES LLM Sorting Operator. We model an LLM-based ordering operator, LLM-order by, that takes a list of n keys X and a natural-language ordering criterion c, and returns a ranked list consistent with c, namely a total order π after deterministic tie-breaking. Keys may represent arbitrary objects, such as database row identifiers, document IDs, or named entities. The criterion is expressed in free text (e.g., “sort by height ascending; break ties alphabetically” or “rank passages by relevance to the query”). In Example 1, the keys are report id values and the criterion is the natural language urgency

specification used in LLM-order by. The operator is accessed solely through a generative interface: given any subset B ⊆ X and the criterion, the LLM returns an ordered list containing exactly the elements of B. Extracting Pairwise Relations from Batch Outputs. For a batch size m ≥ 2, let B = {b1 , . . . , bm } be a batch of keys. The LLM returns a permutation σ(B) = (x1 , . . . , xm ) of B, which we interpret as the set of strict pairwise relations xi ≻ xj ∀1 ≤ i < j ≤ m, i.e., the total order on B implied by the listed sequence. This interpretation applies uniformly across tasks: in value-based sorting it captures numeric or ordinal comparisons, and in passage ranking it captures pairwise relevance preferences with respect to a query. Maintained Relation Set, Closure, and Consistency. The algorithm maintains a set R of ordered pairs (a, b), each indicating that a is strictly preferred to b under the criterion. After each batch response, all implied pairwise relations are added to R, and the set is immediately closed under transitivity. Any relation already implied by R is skipped in future queries. When inserting a new pair (x, y), we propagate its transitive consequences using the reflexive sets A = {x} ∪ {a : a ≻ x} and S = {y} ∪ {b : y ≻ b} (equivalently, A = {x} ∪ Greater_than(x) and S = {y} ∪ Less_than(y) in §IV-A), thereby inferring every pair in A × S. If the insertion would contradict existing relations, i.e., create a directed cycle, it is rejected so that R remains a strict partial order. Although the three-round schedule fixes batch membership by the grid layout, before each listwise call we test whether every pair in the scheduled batch is already resolved by closure, and skip the call if so. When a batch is queried because it still contains unresolved pairs, the model may return an ordering that contradicts relations already in R; such edges are discarded before insertion. Graph View and Incremental Indexing. We represent R as a directed graph G = (V, E), where V is the set of keys and an edge u → v indicates (u, v) ∈ R. Since cycle-inducing updates are rejected, G remains acyclic and therefore encodes a strict partial order. To support efficient updates, each key x maintains two indexed sets: Less_than(x) = { y : (x, y) ∈ R }, Greater_than(x) = { y : (y, x) ∈ R }. When a new relation (a, b) is accepted, we update these sets along the predecessors of a and the successors of b, thereby incorporating all transitive consequences of the insertion. Extracting a Total Order. Let in(x) = |Greater_than(x)| denote the in-degree of x in G. We obtain a linear order by performing a topological traversal, such as Kahn’s algorithm [25]: repeatedly select a vertex with in(x) = 0, append it to the output, remove it for the purpose of degree updates, and decrement the in-degrees of its out-neighbors. When multiple vertices have in-degree zero, we apply a fixed deterministic tiebreak rule (e.g., lexicographic order), which selects one linear extension of G (the lexicographically smallest topological

order under a min-heap). The extension is unique only when G is already a total order. Problem Statement. We formalize the physical execution task addressed in this paper. Problem 1 (Transitivity-aware batched LLM sorting): Input: A key list X = [x1 , . . . , xn ], a natural-language ordering criterion c, a batch size m ≥ 2, and a listwise sorter LLM Sort that, for any batch B ⊆ X with 2 ≤ |B| ≤ m, returns a permutation σ(B) of B. Output: A deterministic total order π over X. Interaction: The algorithm selects batches B1 , . . . , BT (|Bt | ≤ m), collects LLM Sort outputs σ(Bt ) by querying these batches, and inserts the resulting pairwise relations into a relation graph G under transitive closure. Batches whose pairs are already resolved are skipped, whereas any edge that would introduce a cycle in G is excluded. When the schedule terminates, π is extracted from G using Kahn’s topological sort with lexicographic tie-breaking among incomparable keys. Objective: Minimize the number of listwise calls T while ensuring π aligns closely with the task reference order (Kendall’s τ for total-order tasks, nDCG for passage ranking; see §VI). Pairwise sorting (e.g., quicksort with an LLM comparator, QS1 ) needs Θ(n log n) calls, each  settling one pair. A listwise call on m keys orders up to m 2 pairs at once, so our n logm n) calls, three-round batched schedule (§IV) needs O( m matching the lower bound for listwise sorting (§IV-A5), and transitivity-based skipping lowers the realized count further. IV. M ETHODOLOGY This section presents Transitive Batched Sort (TBS) in three parts: the algorithm under a perfect listwise oracle (§IV-A); a direct-edge reachability index that avoids the quadratic memory of explicit transitive closure (§IV-B); and a validation layer that converts raw LLM responses into permutations (§IV-C). Heuristic optimizations for cost-efficient deployment of TBS in practice are presented in §V. A. Transitive Batched Sort 1) Oracle and Shared State: A perfect oracle returns, for any batch B with 2 ≤ |B| ≤ m, the true permutation of B under criterion c. TBS maintains three structures that every procedure reads and updates: 1) the relation graph G = (V, E), kept closed under transitivity; 2) the unresolved neighborhood of each key, i.e., the set of keys whose relative order to x is not yet known in R (we write x ? y when neither x ≻ y nor y ≻ x are known), U [x] = { y ̸= x : x ? y }. 3) the number of unresolved unordered pairs, X u = 12 |U [x]|. x∈X

 Initially, E = ∅, U [x] = X \ {x} for all x ∈ X, and u = n2 . Logically, G is a total order if and only if u = 0. The closed graph G, the sets U [·], and the counter u serve only

Algorithm 1 Perfect Oracle Transitive Batched Sort Input: key set X with n = |X|, ranking criterion c, batch size m ≥ 2 Output: total order π over X Shared state: relation graph G = (V, E) over V = X, unresolved neighborhoods U [·], and unresolved-pair counter u, read and updated by Algorithms 2 and 3 1: G ← (V = X, E = ∅) 2: U [x] ←X \ {x} for all x ∈ X 3: u ← n 2 4: Schedule(X) {three-round recursive schedule} 5: Pack() {resolve remaining unresolved pairs} 6: return π ← Topological Sort(G)

as a logical specification of the algorithm, since materializing them explicitly requires Θ(n2 ) storage, which is prohibitive at scale. In practice they are never materialized; they are derived on demand from a sparse direct-edge DAG (§IV-B), which keeps memory linear in n and the number of stored preferences. As a consequence, the test u = 0, which is O(1) under explicit closure with a maintained counter, is no longer O(1) in the implementation, where u is recovered by blocked column sweeps. 2) Batch Grid: For a key list X and k = ⌈|X|/m⌉, TBS splits X into columns C0 , . . . , Ck−1 of at most m consecutive keys. Let Cj [r] be the r-th key of Cj . Row r is Rr = {Cj [r] : 0 ≤ j < k, r < |Cj |}. Diagonal d (d = 0, . . . , m+k−2, but  may be fewer if the last column is incomplete) is Dd = Cj [r] r + j = d, 0 ≤ j < k, r < |Cj | , so |Dd | ≤ min(m, k). A diagonal with fewer than two keys contains no pair to compare and is never queried. This includes D0 = {C0 [0]} and, when the last column is full, Dm+k−2 = {Ck−1 [m − 1]}. A useful way to read the grid is by pair families: columns cover intra-column comparisons, rows propagate order across columns at matched ranks, and diagonals cover the residual cross-rank boundary interactions left after the first two rounds. 3) Algorithm: TBS is organized as three algorithms that operate on a shared state (the relation graph G, the unresolved neighborhoods U [·], and the counter u). Algorithm 1 is the main procedure: under a perfect oracle it runs the three-round schedule of Algorithm 2 once on X, then calls PACK once to order the remaining unresolved pairs, after which u = 0 and the topological order of G is unique. Algorithm 3 defines the two primitives through which oracle calls are issued: R ESOLVE, which sorts one batch with a single oracle call (skipped when every pair in the batch is already ordered) and merges the answer into G, and PACK, which builds batches for the pairs left unresolved and sends them to R ESOLVE. Given a key list X, Schedule (Algorithm 2) issues a single Resolve call if |X| ≤ m. Otherwise, it splits X into k = ⌈|X|/m⌉ columns and proceeds in three rounds. Round 1 resolves each column and keeps it in sorted order, yielding k disjoint chains. Round 2 forms each row Rr from the rth keys of the sorted columns and schedules it recursively on the same G, U [·], and u. Since |Rr | ≤ k < |X|, the recursion terminates. Because each sorted column is a chain

Algorithm 2 Schedule(L): Three-round Schedule on Key List L Input: key list L Uses: batch size m and shared state G, U [·], u Effect: updates G, U [·], and u 1: if u = 0 or |L| < 2 then 2: return 3: if |L| ≤ m then 4: Resolve(L) 5: return 6: k ← ⌈|L|/m⌉ 7: split L into columns C0 , . . . , Ck−1 , each of size at most m 8: Round 1: Column sorting 9: for j = 0 to k − 1 do 10: Resolve(Cj ); keep Cj in sorted order 11: Round 2: Row sorting with recursion 12: for r = 0 to m − 1 do 13: Rr ← {Cj [r] : 0 ≤ j < k, r < |Cj |} 14: Schedule(Rr ) {|Rr | ≤ ⌈|L|/m⌉ < |L| for |L| > m} 15: Round 3: Diagonal stitching 16: for d = 1 to m + k − 3 do 17: if u = 0 then 18: return 19: Dd ← {Cj [r] : 0 ≤ j < k, 0 ≤ r < |Cj |, r + j = d} 20: if |Dd | ≥ 2 then 21: Resolve(Dd )

Algorithm 3 Oracle-call Primitives: Resolve and Pack 1: procedure Resolve(B) 2: if |B| < 2 then 3: return 4: if there exist a, b ∈ B such that b ∈ U [a] then 5: σ ← Oracle Sort(B, c) {true order of batch B under criterion c} 6: insert into G all pairwise relations implied by σ 7: update G incrementally under transitivity 8: for each newly resolved unordered pair {x, y}, remove y from U [x] and x from U [y] 9: update u 1: procedure Pack() 2: while u > 0 do 3: b ← arg maxx∈X |U [x]| 4: B ← {b} {seed with the key of highest unresolved degree} 5: while |B| < m do 6: s ← maxc∈B / |U [c] ∩ B| 7: if s = 0 then 8: break 9: d ← arg maxc∈B / |U [c] ∩ B| 10: B ← B ∪ {d} 11: Resolve(B)

with position 0 highest, a row answer x ≻ y with x = Ci [r] and y = Cj [r] implies, by transitivity, that every key at or above x in Ci precedes every key at or below y in Cj . This yields (r + 1)(|Cj | − r) cross-column pairs, which, over all r, 2 is at most m+1 when |Cj | = m. Round 3 resolves the 2 diagonals D1 , . . . , Dm+k−3 . Keys on a diagonal lie in pairwise different rows and columns, so Rounds 1–2 never compare them directly; each diagonal call stitches adjacent rows across column boundaries. The schedule returns as soon as u = 0. Resolve(B) first checks U [·] for an unresolved pair inside the batch B; if there is none, no call is issued, so batches already settled by transitivity cost nothing. Otherwise, one oracle call returns σ(B) = (x1 , . . . , x|B| ), whose edges xi ≻ xj for i < j are merged one at a time. An edge a ≻ b is skipped if b ∈ Less_than(a), since it is already

known, and rejected if a ∈ Less_than(b), since it would close a cycle; rejection cannot occur under the oracle, whereas under an LLM the edge is discarded and counted as a contradiction. Otherwise, let A = {a} ∪ Greater_than(a) and S = {b} ∪ Less_than(b). By transitivity, every pair (a′ , b′ ) ∈ A×S not yet in E is inserted, a′ and b′ are removed from each other’s neighborhoods, and u is decremented once per pair. Since each unordered pair leaves U [·] at most once, the amortized cost of removals is O(n2 ) over the whole run. Locating which pairs of A × S are new, however, costs O(|A| |S|) per merge (up to O(n2 ) in the worst case per call), so without a structure that enumerates only new pairs the total scan cost can reach O(T n2 ); §IV-B gives the efficient directedge implementation used in practice. The diagonal phase need not resolve every cross-pair. For example, the relations a ≻ b, a ≻ c, b ≻ d, and c ≻ d leave the order of b and c unknown if no batch contains both keys. Such residual comparisons are exactly those recorded in the unresolved neighborhoods U [·]. To resolve them, Pack greedily builds each batch: it seeds the batch with the key of highest unresolved degree, then repeatedly adds the key that shares the most unresolved pairs with the current batch. Every packed batch therefore contains at least one unresolved pair, so each call to Resolve strictly decreases u under a perfect oracle, which guarantees termination. Because Pack is driven by U [·], it examines only  the leftover unresolved pairs and never rescans the full n2 pair space. 4) Correctness: Under the oracle, every accepted edge is correct and no insertion is rejected, so G remains a transitively closed subgraph of the true order. Since Pack terminates only when u = 0, every pair of keys is eventually ordered, and a topological sort of G therefore recovers the true total order (τ = 1). Under a noisy comparator, cycle-inducing edges are rejected, preserving the acyclicity of G. Consequently, the output is always a valid linear extension of the accepted preferences, with remaining incomparable keys ordered by a deterministic lexicographic tie-break rule. 5) Cost: We measure operator cost as the number of listwise LLM calls, counting each batch request as a single call regardless of its size (2 ≤ |B| ≤ m). Because calls differ in length, we also report total tokens and USD cost for every run (§VI-A4). Ignoring transitivity-based skipping, the call complexity of S CHEDULE (Algorithm 2, all rows) on an input of size n satisfies n  l n m +O +m , T (n) ≤ m T m m where Round 1 issues at most ⌈n/m⌉ column calls, Round 2 recursively sorts m rows of size at most ⌈n/m⌉, and Round 3 evaluates at most ⌈n/m⌉ + m − 1 diagonal batches. Level i of the recursion has mi subproblems of size n/mi , each issuing O(n/mi+1 +m) calls, so level i issues O(n/m+mi+1 ) calls. Summing  over the logm n levels, the first term gives n logm n and the second, a geometric series dominated O m by the deepest level, gives O(n). Hence n  T (n) = O logm n + n . m

Each call on m keys reveals at most log2 m! of the log2 n! bits needed, so any listwise scheme requires Ω(log n!/ log m!) = Ω((n/m) logm n) calls; the leading term of S CHEDULE matches this bound. The bound concerns S CHEDULE only; PACK that guarantees completeness, adds a few more calls. B. Memory-Efficient Reachability Index Explicit transitive closure (§IV-A) stores every known and every open pair, so its memory is Θ(n2 ) regardless of progress, and merging an edge a ≻ b inserts one pair for every ancestor of a and descendant of b (including a and b themselves), up to n2 /4 pairs per merge1 . We instead store only the accepted answers as a sparse DAG and derive all closure quantities on demand, so memory scales with the number of answers rather than with n2 , and each insertion touches only the affected part of the graph. The index is purely an implementation change: it issues the same batches, accepts and rejects the same edges, and produces the same output π as explicit closure. 1) Direct Edges: Let H = (X, Ed ) contain only the edges accepted from listwise answers, and write x ⇝ y if H has a directed path of length at least one2 from x to y. The closure G is then defined by x ≻G y ⇐⇒ x ⇝ y. Resolve(B) examines the pairs of σ(B) = (x1 , . . . , x|B| ) in a fixed order: consecutive pairs (xi , xi+1 ) first, then (xi , xj ) with j ≥ i+2. A pair (a, b) is skipped if a ≻G b, rejected as a contradiction if b ≻G a, and otherwise appended to Ed . If no consecutive pair is rejected, the path x1 → · · · → x|B| lies in G, so all remaining pairs are already implied and are skipped without testing. Otherwise, the descendants and ancestors of each xi are marked once by a pruned search, and the marks are updated after each insertion, which yields the same outcome as testing every pair individually. Because acceptance depends only on reachability, which is exactly the relation stored by explicit closure, both implementations make identical decisions. The memory is O(n + |Ed |), where Ed holds at most one edge per consecutive pair of each answer, plus a few non-consecutive insertions. 2) Dynamic Topological Order: To answer reachability queries without storing the closure, we maintain a topological order of H that bounds the search region of each query and is repaired locally after each insertion. In particular, we maintain a bijection ord : X → {0, . . . , n − 1} such that (a, b) ∈ Ed =⇒ ord(a) < ord(b), and repair it after each insertion with the algorithm of Pearce and Kelly [27]. Inserting (a, b) with ord(a) < ord(b) requires no change. Otherwise, only the affected region is reordered, where ⇝ is taken to be reflexive for this definition: δF = {v : b ⇝ v, ord(v) < ord(a)}, δB = {v : v ⇝ a, ord(v) > ord(b)}. 1 Let A be a together with its ancestors and S be b together with its descendants, so a merge inserts |A| · |S| pairs. The two sets are disjoint: a key in both would give b ⇝ a, which is rejected before insertion. Hence |A| + |S| ≤ n, and by the AM–GM |A|+|S| 2 ≤ n2 /4. inequality [26], |A| · |S| ≤ 2 2 A zero-length path would give x ⇝ x and hence x ≻ x, i.e., a key ranked above G itself.

The positions ord(δB ∪ δF ) are pooled and reassigned, first to δB and then to δF , each in its previous relative order. The two sets are disjoint because  P b ̸≻G a was verified before the insertion. The cost is O v∈δB ∪δF (1 + deg v) + |δ| log |δ| , with δ = δB ∪ δF , which is local to the region. Any valid initial order yields the same answers, so ord may be seeded from a heuristic ranking to reduce reordering. 3) Pruned Reachability Queries: Every vertex on a path from x to y precedes y in ord (or equals y), hence x ≻G y ⇐⇒ ord(x) < ord(y) ∧ y ∈ ReachH (x; Sy ), where Sy = {v : ord(v) < ord(y)} ∪ {y} and ReachH (x; S) is the set of vertices reached by a depth-first search from x that expands only vertices in S. If ord(x) > ord(y), the query returns false without any search. Chain Shortcuts. Round 1 sorts each column Cj with one listwise call, so every column is a chain  in G: it holds the densest block of known relations ( |C2j | pairs) but requires only |Cj |−1 stored edges. Columns are disjoint and sorted before any other call, so their answers cannot contradict G and are accepted in full. We exploit this structure with a fixed chain cover that stores, for each key x, its column ch(x) and its position pos(x) within it (position 0 is the highest-ranked key), 2n integers in total. Labeling vertices by chain and position and answering queries by per-chain comparisons is a classical technique for compressing transitive closure [28], [29]. In our setting the cover comes at no construction cost: the Round-1 columns are already sorted chains, so no chain decomposition is computed, and the cover stays fixed as edges are inserted. These labels speed up our queries in two ways: 1) Same chain. If ch(x) = ch(y), the column order settles the query without any search: x ≻G y ⇔ pos(x) < pos(y). 2) Early termination. If the search from x reaches a vertex v with ch(v) = ch(y) and pos(v) ≤ pos(y), then v = y or v ≻G y by the chain order. Together with x ⇝ v, transitivity gives x ≻G y, so the search stops with a positive answer without locating y itself. Both rules shorten the search and never change its outcome. Batch Skip Test. Before issuing an oracle call, Resolve(B) tests whether B still contains an unresolved pair (Algorithm 3, line 4). Explicit closure answers this by scanning U [·]. Since U [·] is not materialized here, we instead check whether every pair {a, b} ⊆ B is already ordered in G. Because x ≻G y requires ord(x) < ord(y), each pair needs a query in only one direction, the one consistent with ord, and the chain shortcuts apply. The check stops at the first pair that is ordered in neither direction, so it usually terminates early. If every pair is ordered, the batch is skipped at no cost. Exact Counts by Blocked Column Sweeps. The scheduler repeatedly requires two statistics. The unresolved degree d(x) = |U [x]| is used by Pack to seed each batch with the key of highest unresolved degree (Algorithm 3, Pack, line 3). The total number of unresolved pairs u is used in the termination tests of Schedule (Algorithm 2, lines 1 and 17) and in the

loop condition of Pack (Algorithm 3, Pack, line 2). Under the explicit-closure formulation, these quantities are available directly from the maintained ancestor and descendant sets. In the direct-edge implementation, however, the transitive closure is never materialized. We therefore recover the same counts directly from the DAG H = (X, Ed ) using a blocked column sweep. Recall that the Round-1 columns C0 , . . . , Cw−1 form a chain cover of H. For a block of columns, we perform a reverse sweep in topological order. For each key x and column c, we maintain a transient label  λ[x][c] = min {pos(x) + 1 : ch(x) = c} ∪ {λ[y][c] : (x, y) ∈ Ed }  ∪ {pos(y) : (x, y) ∈ Ed , ch(y) = c} , with min ∅ = +∞. The middle set propagates λ[y][c] from every successor y, whatever column y lies in; only the directposition term is guarded by ch(y) = c. The label identifies the first position in column c that is known to be reachable from x: λ[x][c] = min{p : x ≻G Cc [p]}. Since descendants of x within a chain form a suffix of that chain, the number of descendants of x is |D(x)| =

w−1 X

 max 0, |Cc | − λ[x][c] .

c=0

A symmetric forward sweep computes |A(x)|. The unresolved degree then follows directly as d(x) = (n − 1) − |D(x)| − |A(x)|. Summing |D(x)| over all keys yields the total number of ordered pairs; the number of unresolved pairs is the remaining complement. Thus, the blocked sweep computes the exact statistics required by the scheduler without materializing the transitive closure. Completeness Test. Deciding whether G is a total order requires no count. Since ord is a topological order of H, G is total iff every pair of consecutive keys is a direct edge: C OMPLETE(G) ⇔

ord−1 (i), ord−1 (i+1) ∈ Ed ∀ i < n−1. 

Indeed, if G is total, consecutive keys form covering pairs, which must be direct edges; conversely, the listed edges form a Hamiltonian path, which implies all pairs. The test costs O(n + |Ed |) in the worst case and typically fails at the first missing edge. 4) Packing and Output: Pack seeds each batch with arg maxx d(x), obtained from one pair of sweeps. To extend a batch B, it needs the coverage gain |U [c] ∩ B| of every candidate c, which is maintained incrementally: after adding b′ to B, a forward and a backward search from b′ mark its descendants and ancestors D(b′ ) ∪ A(b′ ), i.e., the keys already ordered with b′ , and every  unmarked candidate gains one. This costs O m (n + |Ed |) per batch. Ties are broken by lexicographic key order. The final order is obtained by

TABLE II: Format validation checks for LLM listwise replies. Check

Requirement

Typical violation

Parsing Minimum length Completeness No extras No duplicates Item matching

|L| ≥ 1 |L| ≥ 2 (if |B| ≥ 2) B⊆L L⊆B each key appears once case-insensitive match to B

empty or unparseable reply single-item list omitted batch key hallucinated item repeated key case or format mismatch

running Kahn’s algorithm on H with a min-heap keyed  by lexicographic rank, in O (n + |Ed |) log n time. A key becomes ready exactly when all its ancestors in G have been emitted, so the output equals the topological order of G with lexicographic tie-breaking. C. LLM Output Validation and Repair A listwise reply is not guaranteed to be a permutation of the requested batch. Before merging, TBS parses the reply into a list L, normalizes item identifiers by case-insensitive matching against the batch B, and verifies that L is a permutation of B (Table II). If any check fails, L is repaired by keeping only keys that appear in both the reply and B, in reply order (first occurrence of each), and dropping tokens that do not match B. A reply that omits keys is re-asked, up to five attempts. If it is still incomplete, the missing keys are appended in presentation order; in our runs this fallback never fired. If fewer than two valid keys remain, the reply is discarded and no edges are merged from that call. Repair therefore preserves the model’s relative order on the keys it actually ranked, and contributes only those edges. Validation addresses format errors only. A well-formed reply that contradicts the preference graph G passes validation and is instead handled by cycle-inducing edge rejection at merge time. V. O PTIMIZATION S TRATEGIES Algorithm 1 assumes a perfect oracle and runs until every pair is ordered (u = 0). With an LLM, each call is costly and replies may be noisy, so fully resolving all n2 pairs is not always worthwhile. This section describes heuristics layered on Algorithm 1 that (i) reduce the number of calls, (ii) control which keys share a batch, and (iii) select the batch size m. They change which batches are issued and when the schedule stops, not how replies are merged into G. Hence G stays acyclic and π remains a linear extension of G (§IV-A). They are not part of the oracle correctness argument, and they may leave u > 0. A. Cost-Reducing Execution Rules Round-2 Row Sorting Options. Algorithm 2 sorts every row recursively. To save calls, Round 2 may instead sort only the head row R0 , either recursively or with overlapping windows of at most m keys. Deeper rows are then related to the rest indirectly through diagonal stitching and transitivity. We use recursive R0 -only as the default in our experiments; sorting every row (Algorithm 2) is evaluated as an ablation (Table V).

Diagonal Batching. Short diagonals have few keys. A call on one of them uses a small part of the batch capacity. Hence, consecutive short diagonals are merged into a single batch of at most m keys, while longer diagonals are issued alone. Early Stopping. Let ut be the number of unresolved pairs  after the t-th Round-3 batch and ρt = 1 − ut / n2 the fraction of ordered pairs. Round 3 (diagonals, then Pack) stops issuing calls as soon as one of three conditions holds: completion (ut = 0); stall, when a fixed number of consecutive executed batches add no new ordered pair; or θ-completion, ρt ≥ θ for a target θ ∈ (0, 1]. If ρt ≥ θ is reached during the diagonals, the remaining diagonals are skipped; otherwise Pack continues until it is reached. Stopping inserts no edge, so π remains a linear extension of G. The ut pairs still unresolved are ordered by the deterministic tie-break of §III, so stopping affects only the order of these pairs. Unresolved Packing. Under the oracle, Algorithm 1 always ends with Pack, which is required for τ = 1. Under an LLM, Pack is an optional switch. It spends additional calls on the residual pairs, and ordering them with noisy replies can add contradictions. We enable it when completeness is preferred over cost and otherwise rely on early stopping. B. Batch Membership and Prompt Order

chosen m is then fixed for subsequent runs on that model and task. The sweep needs a reference order to compute qm ; label-free estimation is left to future work. Geometric knee. For N ≥ 3, let P0 and PN −1 be the callminimum and call-maximum points. The knee i⋆ is the interior point with the largest perpendicular distance to the chord P0 PN −1 [30]. Endpoint-aware utility. We normalize calls and quality to [0, 1], xi − xmin , xmax − xmin Ui = α ỹi + (1 − α) (1 − x̃i ), x̃i =

yi − ymin , ymax − ymin α ∈ [0, 1],

ỹi =

where a smaller α favors fewer calls. We use α = 0.7, weighting quality more than call savings. If an endpoint (i = 0 or i = N −1) has strictly higher utility than the knee, we select that endpoint’s batch size. Otherwise we select mi⋆ . VI. E XPERIMENTAL R ESULTS We evaluate whether Transitive Batched Sort (TBS) improves the quality–cost trade-off of LLM-based ordering by exploiting transitivity to reuse preferences across batched queries. We compare TBS against pairwise, pointwise, and listwise baselines; quantify the API-call savings from transitivityaware optimizations; and analyze how key design choices affect ranking quality and cost. To assess robustness and generality, we evaluate TBS across multiple LLM providers and two benchmark families: total-order recovery (NBA heights, World population) and relevance-based ranking (DL19, SciFact, MovieLens). Our code and data are available at https://github.com/kakinola23/TBS-LLM-OrderBy.

Listwise quality depends not only on m but also on which keys share a batch and in what order they appear in the prompt [10], [19]. In TBS, membership is fixed by the Round1 partition of X into columns {Cj }. The rows (Round 2) and diagonals (Round 3) are derived from the same partition, so a single membership preset controls the entire batch grid. We consider four presets: • Contiguous: split X into consecutive segments of size m Research Questions. in input order (inputs are shuffled once before sorting, so RQ1 Quality–cost trade-off. Can TBS match or exceed the this is already a random partition); ordering quality (Kendall τ , nDCG) of the baseline • Random: re-shuffle X with a second seed before splitting; methods while using substantially fewer LLM API calls? comparing it with contiguous measures how much results RQ2 Contribution of optimizations. How much does each vary between two random partitions; design component (transitivity maintenance with query • Similarity: cluster keys by token-based textual similarity skipping, the reachability index, Round 2 row-sorting and pack clusters into columns of size m; heuristics, and Round 3 early termination) contribute to • Similarity embed: same packing, but clusters use embedreducing API calls and preserving ranking quality? ding similarity. RQ3 Robustness across models and tasks. How do quality Keys are listed in partition order in every prompt. Which preset and cost vary across LLM providers and across the totalworks best depends on the task and model; we study this in order and relevance-based benchmarks? our experiments. RQ4 Batch-size sensitivity. How does the batch size m, together with the proposed knee/endpoint selection strategy, C. Batch-Size Selection affect quality and cost? The batch size m trades the number of LLM API calls RQ5 Batch strategies. How do Round 1 membership presets against quality. A small m yields more columns, rows, and (contiguous, random, similarity, similarity embed) indiagonals, hence more calls. A large m strains the context fluence ranking quality and API-call count? window and degrades listwise accuracy. We therefore select m per model and task from a candidate set M with a one- A. Experimental Setup time sweep. For each m ∈ M we run TBS once and record the 1) Datasets and Tasks: We use six benchmarks: two recalltotal number of calls cm and a quality score qm (Kendall’s τ based lists with numeric ground truth, which the model or nDCG). The points (cm , qm ) are sorted by call count and must recall from parametric knowledge (NBA heights and re-indexed as (xi , yi ), i = 0, . . . , N −1, with N = |M|. The World population); large-scale product price sorting (Amazon);

query-driven passage ranking (DL19); claim–document ranking (SciFact); and profile-based movie ranking (MovieLens). a) NBA height: The list contains 200 NBA players with validated heights [31]. Following Zhao et al. [2], X holds player names only and c requests ascending height with alphabetical tie-breaking, so the LLM must rely on parametric knowledge. The ground-truth order sorts by (height, name). b) World population: We use the OrderByLLM benchmark [2]: 200 countries and territories with 2020 populations. As in NBA height, X holds names only, so the LLM must rely on parametric knowledge, and c requests ascending population with alphabetical tie-breaking. The ground-truth order sorts by (population, name), and quality is measured by Kendall’s τ over the full list. c) Amazon price ranking: We sample n=1,000,000 priced products from the Amazon Reviews 2023 product metadata [32], keeping one row per parent ASIN (Amazon’s identifier for a product and its variants), prices in [$0.50, $10,000], and titles of at least three words. Each key is a product title shown with its listed price, so comparisons are nearly errorfree. We therefore use this benchmark to test whether TBS’ bookkeeping and call volume scale to 106 keys, not to measure semantic quality. The criterion c asks for ascending price, with ties broken alphabetically by title. Gold. The listed price defines the total order (ties broken by title, then ASIN), and we score Kendall’s τ against it. The full 1M list is used for the scalability test; smaller runs use fixed random samples of the same corpus (e.g., n=20K). d) DL19 passage ranking: We adopt the DL19 protocol of Zhao et al. [2]: 43 TREC 2019 Deep Learning queries, each paired with its BM25 top-100 MS MARCO v1 passages. For each query, we produce a total order of its 100 passages by relevance to the query text, which serves as the criterion c; keys are passage ids shown with their full text. We report the mean full-list nDCG over the 43 queries. Gold. As in TREC, human assessors provide graded relevance labels (qrels) from 0 to 3, with 3 the most relevant. e) SciFact claim ranking: We adopt the SciFact ranking protocol of LOTUS [1] on a fixed slice of the first 50 of the 300 SciFact test claims [33], each paired with its top-100 abstracts retrieved by E5-base-v2. For each claim, we produce a total order of its 100 abstracts by relevance to the claim text, which serves as the criterion c; keys are abstract ids shown with their text. We report the mean full-list nDCG over the 50 claims. Gold. SciFact provides binary relevance labels (qrels, 0/1) indicating whether an abstract is relevant to the claim. f) MovieLens personalized ranking: MovieLens [34] has also been used to compare pointwise, pairwise, and listwise LLM prompts [8]. We fix 63 users with at least 70 ratings and sample n=70 of each user’s rated movies to sort. The criterion c is a short natural-language user profile; keys are movie ids shown with title and genre. Gold. User ratings (1– 5) serve as graded gains for full-list nDCG, and we report the mean nDCG over the 63 users. 2) Algorithms and Baselines:

a) Proposed method: We run TBS (Algorithms 1–3) with an LLM in place of the oracle and six-check validation (§IV-C). Table III names the variants we study. TABLE III: Named TBS variants. Name

Axis

TBS

Default

Setting / change

Round 1; recursive R0 Round 2; diagonals then Pack (θ=1.0); transitive inference; reachability index TBS-NoReachIndex Index Without the reachability index (heavy full-pair bookkeeping) TBS-AllRows Round 2 Sort every row recursively (Algorithm 2) TBS-Window Round 2 Windowed sort of R0 (overlapping windows of size ≤m) TBS-EarlyStop Round 3 Stop diagonals when ρt ≥ θ (θ=0.9 when enabled) TBS-Pack Pack Enable unresolved Pack after the schedule TBS-NoTrans Transitivity Direct edges only: no skip of resolved batches, no cycle rejection (RQ2 ablation)

b) Baselines: We compare TBS against the ordering paradigms of §II-A (Table I), each instantiated by a prior system or prompt design (listed below). We reimplement every baseline and run it on each of our datasets under the same LLM, temperature, shuffled input, evaluation keys, and metrics as TBS. Within each comparison table, TBS and all baselines therefore share one LLM (GPT-4o in RQ1; GPT-4.1, GPT-4o, and GPT-4o-mini when three models are reported). Table I lists further methods that we do not run as baselines, because they target a different problem. LOTUS [1] and ListK [7] are semantic top-K operators; the full-sort path of LOTUS is pairwise quicksort, which we include as QS1 . LLMRankFusion [15] aggregates several rankings, and trained learning-to-rank rerankers [3], [18] require labeled training data. Sliding-window listwise rerankers [11], [16] and Setwise prompting [17] can produce a full order, but they are designed for top-K reranking of retrieved candidates. Among listwise schedules, we therefore compare against OrderByLLM merge sort, which targets a complete ORDER BY. Pairwise ranking prompting [9] is represented by QS1 . • Pairwise quicksort (OrderByLLM QS1 [2]): quicksort with an LLM pairwise comparator [8], [9]. Each comparison is one LLM call that orders a single pair, so the sort issues O(n log n) calls. • Pointwise scoring (n calls): one prompt per key asks the LLM for a numeric score (e.g., predicted height or relevance); replies are parsed as floats, and keys are sorted by score in the direction required by c [2], [8]. For example, if the LLM returns 2.01, 1.96, and 2.11 for PlayerA, PlayerB, and PlayerC, ascending-height order is PlayerB ≺ PlayerA ≺ PlayerC. • OrderByLLM listwise merge sort [2]: batched external merge sort that sorts contiguous runs of m keys and then merges runs with further listwise calls. Unlike TBS, it does not reuse relations revealed by earlier calls. We run it at the same batch size m as TBS in each experiment.

3) Models: We evaluate TBS with four LLMs: GPT-4.1, GPT-4o, and GPT-4o-mini. GPT-5-nano is used only for Amazon price ranking 3 . All calls use temperature 0, except GPT-5-nano, whose API accepts only the default temperature. 4) Metrics: a) Quality: For NBA, World population, and Amazon (each is a single list of n keys), we report Kendall’s τa between the predicted ranking π and the ground-truth ranking π ⋆ : τa (π, π ⋆ ) =

C −D  , n 2

where C (resp. D) is the number of key pairs whose relative order agrees (resp. disagrees) under π and π ⋆ , and τa =1 indicates a perfect match. Since gold ties are broken by name or title, both orders are total and no tie correction is needed. For DL19, SciFact, and MovieLens, we report the mean of per-instance full-list normalized discounted cumulative gain (nDCG). Given graded gains gi (DL19: TREC 0–3; SciFact: binary 0/1; MovieLens: ratings 1–5) and predicted ranks ri , DCG =

n X

gi , log2 (ri + 1) i=1

nDCG =

DCG , IDCG

where IDCG is the DCG of the ideal ranking by gi . We average nDCG over the instances of each benchmark: nDCGQ over the 43 DL19 queries, nDCGC over the 50 SciFact claims, and nDCGU over the 63 MovieLens users. b) Cost: We report three cost metrics: (i) the number of LLM calls per sort (per query, claim, or user on multi-instance datasets), excluding the optional robustness check; (ii) total tokens (prompt plus completion, as returned by the provider); and (iii) estimated USD cost at the model’s published list rates. Calls and dollar cost capture different costs and are reported separately: calls are limited by API rate limits and per-request overhead, whereas dollar cost depends on tokens, so a method with many short prompts, such as pointwise scoring, can issue more calls than TBS yet cost less. 5) Implementation: TBS is implemented in Python 3. All batch calls share one listwise prompt layout with structured output, following the protocol of Zhao et al. [2]; tasks differ only in how keys are rendered (names, passage or claim text, movie title and genre, or Amazon title with price). Each prompt also states the alphabetical tie-break of its gold order. a) Batch size: We select m per model and dataset from the candidate set M = {4, . . . , 14} using the procedure of §V-C. For GPT-4o the sweep selects m=10 on every dataset, so all RQ1 comparisons use m=10; in RQ3, each model runs at its own m, since smaller models order fewer items reliably per call. For Amazon, which targets million-item lists, we sweep larger candidates MAmazon = {10, 20, 40, 75} at n=200 and choose m=40: m=20 and m=40 tie on quality and cost, and the larger value halves the number of Round-1 columns at n=106 . When early stopping is enabled, we use θ=0.9 with a Round 3 stall limit of 2; all other runs use θ=1.0. 3 Because prices are shown in the prompt, the task requires no factual recall and tests only whether TBS’s bookkeeping and call volume scale to 106 keys; a small model suffices and keeps the million-key run affordable

TABLE IV: RQ1: QS1 , pointwise, merge, and TBS (GPT-4o, m=10). TBS uses the best Round 2 setting per dataset. Amazon uses n=1,000. Dataset

Metric

QS1

PW

Merge

TBS

NBA

τ ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.943 1,483 0.49 3.07

0.938 200 0.05 0.34

0.879 148 0.09 0.64

0.876 97 0.06 0.43

Population

τ ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.976 1,421 0.37 2.01

0.986 200 0.04 0.21

0.933 152 0.08 0.58

0.944 121 0.07 0.45

Amazon

τ ↑ # calls↓ Tokens (M)↓ Cost ($)↓

1.000 10,351 3.53 16.92

1.000 1,000 0.25 1.21

0.999 1,051 0.90 5.10

0.972 643 0.52 2.91

DL19

nDCGQ ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.907 30,913 15.59 79.21

0.855 4,300 1.62 6.28

0.916 2,347 3.33 15.43

0.921 1,790 2.24 10.49

SciFact

nDCGC ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.849 44,047 42.11 169.59

0.691 5,000 3.07 10.83

0.850 2,511 9.22 33.14

0.854 2,200 6.98 25.48

MovieLens

nDCGU ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.887 24,424 7.76 20.03

0.870 4,410 2.34 11.35

0.866 2,141 2.26 13.83

0.879 1,832 0.87 2.61

b) Baselines: All baselines are reimplemented under the same LLM, temperature, shuffled input, and evaluation keys as TBS, with merge sort run at the same batch size m. B. Results Due to space constraints, we report results for RQ1 and RQ2 here; results for RQ3–RQ5 appear in the Appendix. 1) RQ1: Quality–Cost Trade-off: Following the protocol of §VI-A2, we compare TBS with pairwise, pointwise, and listwise baselines under a single LLM (GPT-4o) across all six datasets, using the best Round 2 setting per dataset from Table V. Table IV reports ranking quality and execution cost. a) Pairwise QS1 : Compared with pairwise quicksort, TBS consistently achieves substantial cost reductions in API calls, tokens, and monetary expense. The gap arises because TBS reuses preferences through transitive inference, whereas QS1 resolves comparisons independently. In terms of quality, the picture is mixed. QS1 remains stronger on the recall-based sorting tasks, where the model can often answer individual comparisons directly from memorized facts. However, TBS exceeds QS1 on DL19 and SciFact, and trails slightly on MovieLens (0.879 vs. 0.887), suggesting that aggregating evidence across listwise batches is often more effective when ranking requires nuanced comparative judgments rather than factual recall. b) Pointwise scoring: Pointwise scoring is competitive on NBA, population, and Amazon ranking because each item has an underlying absolute attribute that can be estimated

TABLE V: RQ2 ablations: Q (quality) denotes τ on NBA/Population/Amazon and mean full-list nDCG on DL19/SciFact/MovieLens; # is LLM calls; Tokens (Tok) in M. (a) NoTrans vs. TBS (GPT-4o-mini). (b) ReachIndex (RI) vs. explicit closure on Amazon (GPT5-nano, m=40); τ /#/Tok/$ match for both backends; peak memory (mem.) in MB; 20K/1M use only RI with θ=0.9. (c) θ=0.90 vs. full packing (GPT-4o; Amazon1k : GPT-5-nano). (d) Round 2 R0 /all-rows × recursive (Rec.)/window (Win.). (a) Transitivity

(b) Reachability (Amazon)

NoTrans Dataset

Q↑

TBS

#↓ Tok↓

$↓

Q↑

#↓ Tok↓

Shared $↓

NBA (m=4) 0.354 3,436 1.18 0.41 0.395 306 0.09 0.02 Pop. (m=6) 0.946 1,532 0.64 0.25 0.952 202 0.08 0.03 DL19 (m=5) 0.915 24,469 19.03 4.71 0.900 4,522 3.40 0.85 SciFact (m=4) 0.841 44,545 70.56 14.72 0.871 7,392 11.48 2.42 ML (m=10) 0.848 5,859 3.06 0.59 0.878 1,784 0.86 0.16

τ↑

#↓

Tok↓

$ ↓ NoRI

RI NoRI

RI

200 0.9999 500 0.9997 1,000 0.999

57 94 171

0.13 0.39 0.96

0.04 2.19 0.05 2.5 0.13 34.8 0.40 17.0 0.33 495.1 0.41 49.8

0.1 0.6 0.6

n

20K 1M

Dataset

Q↑

#↓ Tok↓

NBA 0.851 64 Population 0.867 67 Amazon1k 0.949 102 DL19 0.885 1,279 SciFact 0.528 1,469 MovieLens 0.876 1,320

0.946 1,421 11.18 3.78 0.923 91,383 829.45 286.37

R0 only

Full $↓

Q↑

#↓ Tok↓

0.04 0.28 0.876 97 0.04 0.24 0.944 121 0.50 0.17 0.9997 171 1.64 7.71 0.921 1,790 4.64 17.01 0.854 2,200 0.63 1.90 0.879 1,832

– –

– –

– –

– –

(d) Round 2 (R0 /all-rows × Rec./Win.)

(c) Early stop (θ=0.90 vs. full) θ=0.90

Time (s)↓ Peak MB↓

$↓

0.06 0.43 0.07 0.45 0.96 0.33 2.24 10.49 6.98 25.48 0.87 2.61

independently. In such settings, assigning a score to each key is both simple and accurate. This advantage largely disappears on relevance and preference ranking tasks, where quality depends on relative comparisons rather than absolute values. There, TBS consistently outperforms pointwise scoring, indicating that listwise reasoning captures contextual relationships that independent scoring prompts fail to model reliably. c) Listwise merge sort: The comparison with merge sort isolates the effect of transitive reuse, since both methods rely on listwise prompting. Across datasets, TBS achieves comparable or higher ranking quality while requiring fewer LLM interactions and lower overall cost. The advantage stems from maintaining a preference graph and avoiding batches whose ordering is already implied by earlier answers, whereas merge sort repeatedly revisits previously established relations as part of its fixed merge schedule. d) Takeaway: The results reveal a clear task-dependent trade-off. Pointwise scoring is the strongest option when the ranking criterion corresponds to an independently estimable numeric attribute, such as height or population. In contrast, TBS is consistently more effective for semantic relevance and preference ranking, where relative comparisons matter more than absolute scores. Relative to pairwise and listwise baselines, TBS achieves these quality levels with substantially fewer LLM calls by reusing previously acquired preferences rather than repeatedly querying them. Overall, the results support the central premise of TBS: transitivity-aware preference reuse yields significant efficiency gains while preserving, and often improving, ranking quality on semantic ordering tasks. 2) RQ2: Contribution of Optimizations: We ablate one switch at a time from the default (§VI-A5). Unless noted, runs use GPT-4o, m=10, and the prompts/inputs of Table IV. Table V summarizes all four ablations. Transitivity. TBS-NoTrans skips no batch and packs until every pair is observed (Table Va; GPT-4o-mini at its RQ3 m). Transitivity cuts calls by 3–11× on every dataset. Quality is

Rec. Dataset

Q↑

All rows

Win. #↓

Q↑

Rec. #↓

Q↑

Win. #↓

Q↑

#↓

NBA 0.876 97 0.852 94 0.841 108 0.861 103 Population 0.932 101 0.926 98 0.944 121 0.927 109 DL19 0.921 1,790 0.921 1,790 0.911 1,847 0.911 1,847 SciFact 0.839 2,102 0.839 2,102 0.854 2,200 0.854 2,200 MovieLens 0.879 1,832 0.879 1,832 0.870 2,085 0.870 2,085 Amazon1k 0.999 171 0.999 171 0.999 165 0.999 165

mixed: NoTrans leads only on DL19; TBS leads on the other four, so the main win is still cost under a noisy comparator. Reachability index. On Amazon (GPT-5-nano, m=40), both backends replay the same answers, so τ , calls, tokens, and $ match (Table Vb). ReachIndex is 45–1,200× faster with 25– 83× less memory, enabling n=20K (τ =0.946) and n=1M (τ =0.923, $286; θ=0.9). Early stopping. Stopping Round 3 once ρt ≥ θ saves 28–45% of calls at θ=0.90 (Table Vc). NBA/MovieLens stay near full quality; SciFact drops sharply because one relevant abstract per claim often remains unresolved. Round 2. Recursive R0 -only is best or tied on NBA, DL19, MovieLens, and Amazon at the fewest or nearfewest calls (Table Vd); windows cut a few more calls on NBA/population. All-rows helps only population (+0.012) and SciFact (+0.015), at 5–20% more calls. Token and dollar costs track the call counts. Takeaway. Transitive reuse is the main cost lever; the reachability index enables 106 keys; recursive R0 is a sound default; θ<1 is reasonable when relevance is spread over many keys. VII. C ONCLUSIONS We presented Transitive Batched Sort (TBS), a listwise ORDER BY operator that records preferences in an acyclic

graph and skips pairs already implied by transitivity. A directedge reachability index keeps memory linear and lets TBS scale to 106 keys on Amazon. On the six datasets with GPT4o baselines, TBS uses 12–20× fewer calls than pairwise quicksort and 1.1–1.6× fewer than listwise merge sort, with higher quality than merge on four datasets (0.003 lower on NBA and 0.027 lower on Amazon) and the highest quality across all methods on DL19 and SciFact. TBS is best for budget-constrained ranking without an absolute numeric scale; while pointwise scoring remains stronger on NBA, Population, and Amazon, and QS1 on NBA, Population, Amazon, and MovieLens. Future work includes transitivity-aware top-K selection, cost-based access-path selection, and setting optimal m and θ without a sweep.

R EFERENCES [1] L. Patel, S. Jha, M. Pan, H. Gupta, P. Asawa, C. Guestrin, and M. Zaharia, “Semantic operators: A declarative model for rich, AI-based data processing,” 2024. [2] F. Zhao, J. Chen, Y. Pan, T. Rabbani, Sohaib, D. Agrawal, A. El Abbadi, P. Aggarwal, A. Datta, and D. Tsirogiannis, “Access paths for efficient ordering with large language models,” 2025, code released as the OrderByLLM benchmark. [3] T.-Y. Liu, Learning to Rank for Information Retrieval. Springer, 2011. [4] V. Karpukhin, B. Oguz, S. Min, P. Lewis, L. Wu, S. Edunov, D. Chen, and W. Yih, “Dense passage retrieval for open-domain question answering,” in Conference on Empirical Methods in Natural Language Processing (EMNLP), 2020, pp. 6769–6781. [5] J. Johnson, M. Douze, and H. Jégou, “Billion-scale similarity search with gpus,” IEEE Trans. Big Data, vol. 7, no. 3, pp. 535–547, 2021. [6] G. Graefe, “Implementing sorting in database systems,” ACM Computing Surveys, vol. 38, no. 4, 2006. [7] J. Shin, J. Chang, and F. Nargesian, “ListK: Semantic ORDER BY and LIMIT K with listwise prompting,” 2026. [Online]. Available: https://arxiv.org/abs/2603.17223 [8] S. Dai, W. X. Zhao, J.-r. Xu, Z. Tang, Y. Ye, J. Zhang, and J.-r. Wen, “Uncovering ChatGPT’s capabilities in recommender systems,” 2023. [9] Z. Qin, R. Jagerman, K. Hui, H. Zhuang, J. Wu, J. Yan, L. Shen, T. Liu, J. Liu, D. Metzler, X. Wang, and M. Bendersky, “Large language models are effective text rankers with pairwise ranking prompting,” in Findings of the Association for Computational Linguistics: NAACL 2024. Mexico City, Mexico: Association for Computational Linguistics, 2024. [Online]. Available: https://aclanthology.org/2024.findings-naacl.97/ [10] R. Tang, X. Zhang, X. Ma, J. Lin, and F. Ture, “Found in the middle: Permutation self-consistency improves listwise ranking in large language models,” arXiv preprint arXiv:2310.07712, 2024. [11] X. Ma, X. Zhang, R. Pradeep, and J. Lin, “Zero-shot listwise document reranking with a large language model,” arXiv preprint arXiv:2302.10584, 2023. [12] R. Beigel and J. Gill, “Sorting n objects with a k-sorter,” IEEE Transactions on Computers, vol. 39, no. 5, pp. 714–716, 1990. [13] T. Leighton, “Tight bounds on the complexity of parallel sorting,” IEEE Transactions on Computers, vol. C-34, no. 4, pp. 344–354, 1985. [14] I. D. Scherson, S. Sen, and A. Shamir, “Shear sort: A true twodimensional sorting technique for VLSI networks,” in Proc. International Conference on Parallel Processing (ICPP), 1986. [15] Y. Zeng, O. Tendolkar, R. Baartmans, Q. Wu, L. Chen, and H. Wang, “LLM-RankFusion: Mitigating intrinsic inconsistency in LLM-based ranking,” arXiv preprint arXiv:2406.00231, 2024. [16] W. Sun, L. Yan, X. Ma, S. Wang, P. Ren, Z. Chen, D. Yin, and Z. Ren, “Is ChatGPT good at search? investigating large language models as re-ranking agents,” in Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing. Singapore: Association for Computational Linguistics, 2023. [Online]. Available: https://aclanthology.org/2023.emnlp-main.923/ [17] S. Zhuang, H. Zhuang, B. Koopman, and G. Zuccon, “A setwise approach for effective and highly efficient zero-shot ranking with large language models,” in Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval, 2024. [18] R. Nogueira and K. Cho, “Passage re-ranking with BERT,” 2019. [19] P. Wang, L. Li, L. Chen, Z. Cai, D. Zhu, B. Lin, Y. Cao, L. Kong, Q. Liu, T. Liu, and Z. Sui, “Large language models are not fair evaluators,” in Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Bangkok, Thailand: Association for Computational Linguistics, 2024, pp. 9440–9450. [20] R. Pradeep, S. Sharifymoghaddam, and J. Lin, “Rankzephyr: Effective and robust zero-shot listwise reranking is a breeze!” 2023. [Online]. Available: https://arxiv.org/abs/2312.02724 [21] S. Herbold, “SortBench: Benchmarking LLMs based on their ability to sort lists,” 2025. [Online]. Available: https://arxiv.org/abs/2504.08312 [22] T. Joachims, “Optimizing search engines using clickthrough data,” in Proceedings of the ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2002, pp. 133–142. [23] C. J. Burges, “From RankNet to LambdaRank to LambdaMART: An overview,” Microsoft Research, Tech. Rep. MSR-TR-2010-82, 2010. [Online]. Available: https://www.microsoft.com/en-us/research/ publication/from-ranknet-to-lambdarank-to-lambdamart-an-overview/

[24] A. Marcus, E. Wu, D. R. Karger, S. Madden, and R. C. Miller, “Humanpowered sorts and joins,” Proceedings of the VLDB Endowment, vol. 5, no. 1, pp. 13–24, 2011. [25] A. B. Kahn, “Topological sorting of large networks,” Communications of the ACM, vol. 5, no. 11, pp. 558–562, 1962. [26] G. Hardy, J. Littlewood, and G. Pólya, Inequalities, ser. Cambridge Mathematical Library. Cambridge University Press, 1952. [27] D. J. Pearce and P. H. J. Kelly, “A dynamic topological sort algorithm for directed acyclic graphs,” ACM J. Exp. Algorithmics, vol. 11, p. 1.7–es, 2007. [28] H. V. Jagadish, “A compression technique to materialize transitive closure,” ACM Trans. Database Syst., vol. 15, no. 4, pp. 558–598, 1990. [29] K. Simon, “An improved algorithm for transitive closure on acyclic digraphs,” Theor. Comput. Sci., vol. 58, pp. 325–346, 1988. [30] V. Satopää, J. Albrecht, D. Irwin, and B. Raghavan, “Finding a “kneedle” in a haystack: Detecting knee points in system behavior,” in Proc. ICDCS Workshops, 2011. [31] OpenIntro, “Openintro statistics: Nba player heights dataset,” https:// www.openintro.org, 2025, accessed 2025. [32] Y. Hou, J. Li, Z. He, A. Yan, X. Chen, and J. McAuley, “Bridging language and items for retrieval and recommendation,” arXiv preprint arXiv:2403.03952, 2024. [33] D. Wadden, S. Lin, K. Lo, L. L. Wang, M. van Zuylen, A. Cohan, and H. Hajishirzi, “Fact or fiction: Verifying scientific claims,” in Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP). Online: Association for Computational Linguistics, 2020, pp. 7534–7550. [34] F. M. Harper and J. A. Konstan, “The MovieLens datasets: History and context,” ACM Transactions on Interactive Intelligent Systems, vol. 5, no. 4, pp. 19:1–19:19, 2016. [35] S. Guo, A. Parameswaran, and H. Garcia-Molina, “So who won? dynamic max discovery with the crowd,” in Proc. ACM SIGMOD International Conference on Management of Data, 2012, pp. 385–396. [36] P. Venetis, H. Garcia-Molina, K. Huang, and N. Polyzotis, “Max algorithms in crowdsourcing environments,” in Proc. International World Wide Web Conference (WWW), 2012. [37] S. B. Davidson, S. Khanna, T. Milo, and S. Roy, “Using the crowd for top-k and group-by queries,” in Proc. International Conference on Database Theory (ICDT), 2013. [38] X. Chen, P. N. Bennett, K. Collins-Thompson, and E. Horvitz, “Pairwise ranking aggregation in a crowdsourced setting,” in Proc. ACM International Conference on Web Search and Data Mining (WSDM), 2013. [39] U. Feige, P. Raghavan, D. Peleg, and E. Upfal, “Computing with noisy information,” SIAM Journal on Computing, vol. 23, no. 5, pp. 1001– 1018, 1994. [40] M. Braverman and E. Mossel, “Noisy sorting without resampling,” in Proc. ACM-SIAM Symposium on Discrete Algorithms (SODA), 2008. [41] K. G. Jamieson and R. D. Nowak, “Active ranking using pairwise comparisons,” in Advances in Neural Information Processing Systems (NeurIPS), 2011.

A PPENDIX A N OTATIONS Table VI lists notation used in the paper. TABLE VI: Frequently used notations. Notation

Meaning

n X = {x1 , . . . , xn } c m

number of keys (items) to be sorted input key list submitted to the sorting operator natural-language ordering criterion (prompt) listwise batch size (m ≥ 2); knee sweep tries m ∈ M, then fixes one per model M candidate batch sizes ({4, . . . , 14}; {10, 20, 40, 75} on Amazon) B subset of keys in one listwise LLM call σ(B) = (x1 , . . . , xm ) permutation of B returned by the LLM a≻b strict preference: a ranks above b under c R maintained ordered pairs (a, b) with a ≻ b G = (V, E) relation graph, V = X, edge u → v iff (u, v) ∈ R H = (X, Ed ) sparse DAG of direct edges (G is its transitive closure) π final total order over X (lexicographic tie-break)

A PPENDIX B A DDITIONAL R ELATED W ORK Batched comparators. Ordering k items per call is classical: Beigel and Gill bound k-sorter complexity [12]; Columnsort [13] and Shearsort [14] alternate column and row phases. TBS reuses that grid for Rounds 1–3, but unlike those perfectcomparator schedules it skips batches already implied by earlier answers and rejects contradictions. Crowdsourced sorting. Crowd DB operators also pay per comparison and tolerate noise [24], [35]–[38]; several save questions via transitivity. TBS applies the same idea to listwise LLM calls, with three differences: each call yields up to m 2 preferences, the schedule is the batch grid, and the graph must stay cheap at large n (addressed by the reachability index, §IV-B). Noisy sorting. Theory bounds comparisons under random errors with and without resampling [39], [40] and studies active ranking under geometric assumptions [41]. TBS assumes no error model: it only keeps G acyclic and measures residual disagreement empirically (§C-A). A PPENDIX C A DDITIONAL E XPERIMENTAL R ESULTS A. Quantifying Residual LLM Inconsistency Format validation (§IV-C) ensures that a reply is a permutation of its batch, not that preferences are correct. Two residual inconsistencies remain, summarized in Table VII. TABLE VII: TBS inconsistency (GPT-4o). εreject , η, Malformed: Round 2 R0 audit (NBA/Pop./Amazon: one instance; DL19/SciFact/MovieLens: first 20). Pack calls: full sort to u=0 with all-rows Round 2; NBA/Pop./Amazon: one instance; DL19/SciFact/MovieLens: first 20. Metric

NBA

Pop.

DL19

SciFact

ML

Amz.

εreject ↓ η↓ Pack calls (%) ↓ Malformed (%) ↓

0.067 0.038 12 0.0

0.065 0.063 11 0.0

0.102 0.115 9 0.4

0.113 0.037 11 1.0

0.091 0.178 5 0.0

0.041 0.030 16 0.0

Detectable contradictions. An edge that would cycle G is rejected at merge. With D accepted and Rrej rejected direct edges, εreject = Rrej /(D + Rrej ) is a merge-time conflict rate, not a lower bound on LLM mistakes. Undetectable semantic noise. Edges consistent with G may still be wrong under c. We re-ask stored direct edges pairwise; if C is the fraction whose direction agrees with the stored edge, η = 1 − C. The two rates use different denominators and are not combined. Table VII separates format errors from preference noise. When a listwise reply proposes an edge that would cycle the preference graph G, TBS rejects that edge at merge time: across datasets, εreject ranges from 0.041 on Amazon to 0.113 on SciFact (about 4–11% of candidate direct edges). This rate indicates conflicts with already-accepted structure, not all LLM mistakes. An early wrong edge can close off later correct ones, so a later true preference may be discarded even though the model answered correctly on that batch. That effect helps explain why disabling transitivity (TBS-NoTrans) improves quality only on DL19 (Table V). Edges that do enter G can still be semantically wrong. Re-asking a sample of stored direct edges as fresh pairwise comparisons, the disagreement rate is η=0.030–0.178: lowest on Amazon (prices shown in the prompt) and SciFact, and highest on MovieLens, where preference judgments are more subjective. Separately, under all-rows Round 2 with packing run to completion (u=0), unresolved Pack accounts for 5–16% of all LLM calls (lowest on MovieLens, highest on Amazon). Malformed replies, i.e., outputs that are not a clean permutation of the batch, are at most 1% (SciFact) and 0% on four datasets; every such reply is repaired by retry before any edge is merged. B. RQ3: Robustness across Models and Tasks We compare GPT-4.1, GPT-4o, and GPT-4o-mini under the default schedule (§VI-A5) at each model’s selected m (Table VIII; sweeps in Figure 2). Mini needs smaller m (e.g., population τ =0.952 at m=6 vs. 0.564 at m=10). On total orders, GPT-4o leads NBA (0.876/97 calls) over GPT-4.1 (0.817/110), while mini collapses (0.208/306); population is easy for all (τ ≥0.93; GPT-4.1 highest at 0.972/87). On relevance/preference, quality is close (MovieLens 0.878–0.879; SciFact 0.839–0.871, mini best; DL19 0.900–0.921, GPT-4o best), but mini is cheapest in dollar cost despite often more calls. Takeaway. Model choice matters most when the ranking requires recalling factual knowledge from model parameters (e.g., NBA height and population ranking). Elsewhere, ranking quality is relatively similar across models, and dollar cost is influenced more by token pricing than by call count. C. RQ4: Batch-size Sensitivity We next ask how the listwise batch size m affects quality and cost across models and datasets, and how we select m for the RQ3 runs. Figure 2 sweeps m for GPT-4.1, GPT-4o,

and GPT-4o-mini on NBA, Population, DL19, and MovieLens (contiguous Round 1, diagonals then Pack, θ=1.0), recording quality, calls, tokens, and USD cost; stars mark each model’s selected m. TABLE VIII: RQ3: TBS across LLMs at selected m. Bold is best per row. Dataset

Metric

GPT-4.1

GPT-4o

GPT-4o-mini

NBA

τ ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.817 110 0.06 0.33

0.876 97 0.06 0.43

0.208 306 0.10 0.04

τ ↑ # calls ↓ Population Tokens (M) ↓ Cost ($) ↓

0.972 87 0.04 0.18

0.932 101 0.05 0.36

0.952 202 0.08 0.03

nDCGQ ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.905 2,105 2.27 7.67

0.921 1,790 2.24 10.49

0.900 4,522 3.40 0.85

DL19

nDCGC ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.864 2,032 5.91 15.60

0.839 2,102 6.46 23.77

0.871 7,392 11.48 2.42

nDCGU ↑ # calls ↓ MovieLens Tokens (M) ↓ Cost ($) ↓

0.878 1,893 0.90 2.11

0.879 1,832 0.87 2.61

0.878 1,784 0.86 0.16

SciFact

 Cost vs. quality. Because each listwise call orders up to m 2 pairs, increasing m shortens the three-round schedule and cuts calls, tokens, and dollar cost, with diminishing returns once m is already large. Call counts for GPT-4.1, GPT-4o, and GPT-4o-mini nearly coincide at each m, so the dollar gaps between models are driven mainly by token pricing rather than by how many batches TBS issues. Quality, however, depends on whether the model can still produce a reliable total order over a longer list. GPT-4.1 and GPT-4o remain essentially quality-flat across the sweep: larger batches reduce cost without a clear quality penalty, so the knee/endpoint rule of §V-C selects large m (9–12) to harvest the call savings. GPT-4o-mini does not share that robustness on total-order and passage ranking. On NBA, mini already sits at τ ≈0.21 for m=4 and collapses near zero for m≥6; on Population, quality falls from ≈0.97 at small m to below 0.6 as m grows; on DL19, nDCGQ drops once m exceeds 5–6. In these settings a large m would buy fewer calls at the expense of a broken ranking, so the selector keeps mini at small batches (m=4/6/5 on NBA/Population/DL19). MovieLens is the exception: preference ranking over short movie descriptors stays stable for all three models, and the selector picks m=10 for each. Takeaway. When quality stays flat under longer lists, as with GPT-4.1 and GPT-4o, a larger m mainly reduces calls, tokens, and dollar cost. GPT-4o-mini instead needs a small m on factual total-order and passage ranking, where longer listwise prompts degrade the weaker comparator.

D. RQ5: Execution and Batching Strategies Table IX compares the four Round 1 membership presets of §V-B under GPT-4o (m=10, recursive R0 , diagonals then Pack, θ=1.0). Contiguous and random differ by only 0.002– 0.024 in quality across datasets, so the choice between them barely matters. On NBA and Population, where keys are bare names with little text for clustering, both similarity presets trail contiguous on τ while saving few calls. On passage and preference tasks the text is richer, yet similarity still does not dominate: contiguous remains cheapest or near-tied on DL19 and MovieLens, and only SciFact favors lexical similarity on quality. TABLE IX: RQ5: Round 1 membership (GPT-4o, m=10). Bold is best per row. Dataset

Metric

NBA

τ ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.876 97 0.06 0.43

0.866 0.849 96 93 0.06 0.06 0.41 0.41

0.832 89 0.05 0.39

τ ↑ # calls ↓ Population Tokens (M) ↓ Cost ($) ↓

0.932 101 0.05 0.36

0.908 0.861 95 95 0.05 0.05 0.35 0.34

0.892 96 0.05 0.34

DL19

nDCGQ ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.921 1,790 2.24 10.49

0.923 0.895 1,840 1,824 2.30 2.27 10.91 10.81

0.897 1,806 2.26 10.69

SciFact

nDCGC ↑ # calls ↓ Tokens (M) ↓ Cost ($) ↓

0.839 2,102 6.46 23.77

0.861 0.862 2,110 2,107 6.43 6.45 23.73 23.71

0.838 2,080 6.38 23.48

nDCGU ↑ # calls ↓ MovieLens Tokens (M) ↓

0.879 1,832 0.87 2.61

0.877 0.873 1,855 1,854 0.88 0.88 2.66 2.66

0.873 1,841 0.88 2.64

Cost ($) ↓

Contig. Random Sim. Sim.-emb.

Takeaway. Round 1 membership changes quality more than call count, and contiguous or random is a stable choice on most datasets. On NBA/Population, contiguous leads (τ =0.876/0.932) and similarity trails by 0.027–0.071 with little call savings, consistent with bare-name keys offering weak clustering signal. On DL19/MovieLens, contiguous is cheapest or tied (random ties DL19 at 0.923); similarity trails DL19 by ≈0.025 and stays within 0.006 on MovieLens. SciFact is the exception: lexical similarity (0.862) matches random and beats contiguous (0.839), likely because shared scientific terms put related abstracts in the same Round 1 column and make listwise comparisons easier, whereas embedding clusters are topical and need not align with claim-level support or refute; embedding similarity is cheapest overall but does not improve quality.

GPT-4.1

GPT-4o

GPT-4o-mini

selected m Population

4 6 8 10 12 14 m

4 6 8 10 12 14 m

4 6 8 10 12 14 m

(a) τ

(b) # calls

(a) τ

(b) # calls

−1

10

10−2

0.15

Cost ($)

100

Tokens (M)

0.15 0.1 0.05

0.1 0.05

10−1 10−2

4 6 8 10 12 14 m

4 6 8 10 12 14 m

4 6 8 10 12 14 m

(c) Tokens (M)

(d) Cost ($)

(c) Tokens (M)

(d) Cost ($)

4 6 8 10 12 14 m

0.9 0.88 0.86 0.84

(b) # calls (×103 )

Cost ($)

101 100

4 6 8 10 12 14 m

# calls (×103 )

2

(a) nDCGQ 5 4 3 2

nDCGU

4

6 4 2

2.5 2 1.5 1

4 6 8 10 12 14 m (b) # calls (×103 )

(a) nDCGU

Cost ($)

4 6 8 10 12 14 m

6

Tokens (M)

0.9 0.85 0.8

MovieLens # calls (×103 )

nDCGQ

100

4 6 8 10 12 14 m

DL19

Tokens (M)

400 300 200 100

4 6 8 10 12 14 m

Cost ($)

Tokens (M)

0

1 0.8 0.6 0.4

# calls

0.5

400 300 200 100

τ

# calls

τ

NBA

100

4 6 8 10 12 14 m

4 6 8 10 12 14 m

4 6 8 10 12 14 m

4 6 8 10 12 14 m

(c) Tokens (M)

(d) Cost ($)

(c) Tokens (M)

(d) Cost ($)

Fig. 2: RQ4: batch size m vs. quality, calls, tokens, and cost ($). One line per model; stars mark selected m (star–line gap at the same m is run variation). Contiguous Round 1, diagonals then Pack, θ=1.0; recursive R0 except DL19 Round-2 windows.

Related documents

Record · ID 1767910 · SHA-256 885c1fd6f5d78167
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Bring this data into your agent: Connect via MCP or API · 20 free credits to start · no card required
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive