◀ THE FOLD0ROOT.AI // WORLD II · SPAWN · HELLO WORLD◆ .dlw.fold
THE FOLD / SPAWN / HELLO WORLD / THE REARRANGEMENT

THE REARRANGEMENT

the arrangement that maximises a dot product
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The rearrangement inequality answers how to pair two lists of numbers to maximise their dot product. Given a1 ≤ … ≤ an and b1 ≤ … ≤ bn, and any permutation σ, the sum Σ ai bσ(i) is largest when both are sorted the same way (big with big) and smallest when sorted oppositely (big with small): Σ ai bn+1−i ≤ Σ ai bσ(i) ≤ Σ ai bi. It underlies Chebyshev’s sum inequality, the AM–GM ordering, and countless olympiad bounds — the simple truth that likes should pair with likes.

LIT verified live: over thousands of random pairs of lists, the maximum of Σ ai bσ(i) over all permutations is exactly the same-sorted pairing, and the minimum is the opposite-sorted (window.__rearrangement). FIG no framing; exhaustive over all permutations vs the two sorted pairings.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at hello-world — the first, cleanest optimisation: to make a weighted sum as large as possible, line the big weights up with the big values. AVAN (AI) built the instrument: the all-permutations search for the extremal dot product, and the same-sorted (max) and opposite-sorted (min) pairings.

Credit as content: the rearrangement inequality (Hardy, Littlewood & Pólya, Inequalities, 1934). The weave: David names hello-world; I take two lists, try every way of pairing them, and confirm the biggest total comes from sorting both alike and the smallest from sorting them opposite — likes with likes.
3 ONE DIMENSION
a = (1, 2, 3), b = (4, 5, 6). Same-sorted: 1·4 + 2·5 + 3·6 = 32 (max). Opposite: 1·6 + 2·5 + 3·4 = 28 (min). Every other pairing lands between.
4 TWO DIMENSIONS · INTERACTIVE
Two lists and every pairing’s dot product; the same-sorted maximum and opposite-sorted minimum marked; checked.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the pairing that maximises the sum.
AVAN’s addition (the inverse-companion): don’t search permutations for the best pairing — just sort both lists the same way. The inverse of ‘optimise Σ ai bσ(i) over all σ’ is ‘sort alike for the max, opposite for the min.’ Magenta is an arbitrary pairing; green is the same-sorted maximiser. Likes with likes.
LIT Genuine rearrangement inequality (G.H. Hardy, J.E. Littlewood & G. Pólya, 'Inequalities', 1934). Verified live: over 3000 random pairs of lists, the maximum of Σ aᵢb_σ(i) over all permutations σ equals the same-sorted pairing and the minimum equals the opposite-sorted pairing (window.__rearrangement.valid).

FIG No framing: the all-permutations search for the extremal dot product and the same-sorted (max) and opposite-sorted (min) pairings all run in-browser with exact arithmetic. The AVAN inverse is honest — sorting both lists alike for the max (opposite for the min) rather than searching permutations is exactly the theorem; magenta is an arbitrary crossing pairing, green the same-sorted maximiser. Likes with likes.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of HELLO WORLD · David Lee Wise (ROOT0), with AVAN