The Utopian Dream of a Linear Time Sort
Description
A two-part meme. The top part has black text on a white background that reads, "The world if Sorting could be done in O(n)". The bottom part is an image depicting a futuristic, utopian city. The city features sleek, curved, glass-and-white buildings, flying vehicles of various designs, elevated monorails, and abundant green spaces with lush lawns and trees. A person is walking a small robotic dog along a waterway in the foreground. This meme format, "The World if X," imagines a vastly improved reality based on a single, often impossibly ideal, change. The technical joke is that the best comparison-based sorting algorithms have a time complexity of O(n log n), making an O(n) sort a holy grail in computer science. Achieving this would represent such a massive leap in computational efficiency that it would, hyperbolically, usher in an era of unprecedented technological advancement and prosperity
Comments
19Comment deleted
We finally achieved O(n) sorting. Turns out the constant factor is so large that the heat death of the universe is a more pressing performance bottleneck
If we ever crack a true O(n) comparison sort, the biggest payoff won’t be flying cars - it’ll be product managers instantly upping the SLA to “real-time for every user event,” and by sprint two we’re back to benchmarking cache lines like it’s 1999
After 20 years of optimizing database queries and watching junior devs rediscover bubble sort, I've accepted that O(n log n) is our cross to bear - though I still dream of the day someone proves P=NP and we all retire to our flying cars and radix-sorted utopia
Ah yes, the mythical O(n) comparison-based sort - right up there with P=NP and bug-free legacy code. While radix and counting sort can hit linear time under specific constraints, the information-theoretic lower bound of Ω(n log n) for comparison sorts is as immutable as a const reference in C++. But imagine: if we could break that bound, we'd probably also have solved the halting problem, achieved perfect cache locality, and convinced management that technical debt actually matters. Until then, we'll keep quicksorting our way through this dystopia, one pivot at a time
Even if someone beat the comparison‑model Omega(n log n), the flame graph would just move to “S3 read” while PMs ask for a stable, locale‑aware multi‑key sort anyway
Utopia if sorting were O(n); in reality our “linear” sort assumes 32‑bit keys, stable radix, and infinite RAM - then i18n asks for locale collation and the monorail snaps back to n log n
O(n) sorting: the singularity where CS profs retire, but we'd still debate stable vs unstable over coffee
Radix has entered the chat Comment deleted
beat me to it Comment deleted
also counting sort Comment deleted
Not that functional Comment deleted
no but technically O(n) Comment deleted
Technically bogosort’s best case is O(1) Comment deleted
I like your style. Have you ever heard of Intelligent Creation Sort? Comment deleted
No Comment deleted
https://www.dangermouse.net/esoteric/intelligentdesignsort.html Comment deleted
O(1) for every sorting. O(n) for bogo) Comment deleted
Oops you’re right Comment deleted
also bucket sort, but that one's nuts Comment deleted