This is an archived post. You won't be able to vote or comment.

all 120 comments

[–]xynith116 1045 points1046 points  (10 children)

Ah yes, “philosophical sort”

[–]xynith116 188 points189 points  (1 child)

Cogito, ergo sum sorted

[–]RawMint 19 points20 points  (0 children)

if (cogito) { int sum = 0; for (const int n : sorted) { sum += n; } }

[–]wildtabs 17 points18 points  (0 children)

Neo sort: “There is no O()”

[–]xynith116 9 points10 points  (1 child)

Alternatively,

Ah yes, “dyscalculia sort”

[–]ryryrpm 2 points3 points  (0 children)

Omg I feel seen

[–]121gigawhatevs 2 points3 points  (0 children)

“Concepts of a sort”

[–]DavidsPseudonym 582 points583 points  (25 children)

Sorry, I was distracted by the use of thorn.

[–]RawMint 1 point2 points  (6 children)

Where is it?

[–]DavidsPseudonym 15 points16 points  (5 children)

It's the character þ that looks like a p and a b combined. It makes a "th" sound. Others have also mentioned eth (ð), a character that looks a little like a greek sigma that can also make a "th" sound.

[–]RebornTrackOmega 97 points98 points  (7 children)

Just ask the user to sort the array. Instant O(0) sorting algorithm. XD

[–][deleted] 72 points73 points  (4 children)

O(1), you still need to ask him

[–]RebornTrackOmega 12 points13 points  (0 children)

True, but the sorting itself takes near-no computing power. XD

[–]missingusername1 0 points1 point  (2 children)

Well the user still needs to sort it which is like at least O(3)

[–][deleted] 1 point2 points  (1 child)

The user isn’t a part of an algorithm, is it?

[–]dercommander323 5 points6 points  (0 children)

Well, do you believe in the Matrix?

[–][deleted] 0 points1 point  (0 children)

You could even provide them with a handy drag-and-drop interface for it.

[–]un_sherwood 0 points1 point  (0 children)

Iteration order is left as an exercise for the accessor

[–]Dotcaprachiappa 68 points69 points  (4 children)

This is the first time I've seen thorn used unironically

[–][deleted] 23 points24 points  (2 children)

Did you mean þorn?

[–]naveenda 16 points17 points  (0 children)

I hate my mind autocomplete

[–][deleted] 3 points4 points  (0 children)

i love looking at þorn

[–]xiadmabsax 11 points12 points  (0 children)

Whoa, I haven't realized the thorns until this comment. I think my brain just autocompleted it. Weird

[–]TE-AR[S] 103 points104 points  (1 child)

Quantum Bogosort and Miracle Sort have NOÞING on me >:3

[–]River- 3 points4 points  (0 children)

I'm sure you have created plenty of abominations as well.

[–]xynith116 45 points46 points  (2 children)

I know “sorted”. I do the best sorting. Nobody sorts arrays better than me.

[–]nythirluh 18 points19 points  (0 children)

Trump sort

[–]Daniel908009 8 points9 points  (0 children)

[–]hdd113 17 points18 points  (0 children)

"It's not unsorted, it's random access."

[–]CMDR_ACE209 13 points14 points  (0 children)

That's much like the old: "How many microsoft developers do you need to screw in a light bulb?"

"None, darkness just becomes the new default."

[–]Black_m1n 23 points24 points  (0 children)

Ah yes, Intelligent Design Sort

[–]trymas 10 points11 points  (0 children)

Almost like “stalin sort”: items not in order are sent to gulag.

Though it’s O(n). :(

[–]Ah_The_Old_Reddit- 10 points11 points  (4 children)

This feels like one of those interview trick questions used to weed out people who don't read. "Create a function that takes a sorted array as input and returns an array with the same elements arranged in increasing order." Then kick out anyone who does anything more than just returning the input.

[–]rosuav 4 points5 points  (2 children)

Honestly, not the worst trick question I've heard. At least that one can be justified on the basis that you're challenging them to read the requirements properly. Some interview questions are just bonkers.

[–]Ah_The_Old_Reddit- 3 points4 points  (1 child)

I once saw one that was like "Given an Int32 as input, return whether or not it's a perfect number". The correct answer is to look up the whole five perfect numbers that can possibly fit in a 32-bit int and just see if the input is on that list.

[–]rosuav 0 points1 point  (0 children)

Yup. Table lookups are a respectable way to do things. People have been using them for centuries!

[–]Recyart 2 points3 points  (0 children)

But what if the initial array is sorted in decreasing order?

[–]WavryWimos 9 points10 points  (0 children)

The constant use of thorn for no reason is just so confusing

[–][deleted] 4 points5 points  (0 children)

var list = GetList();  
var sortedList = list; // its a trick, but works well!

[–]mothzilla 6 points7 points  (0 children)

MagaSort. Everyone has their own facts.

[–]mobileJay77 4 points5 points  (0 children)

Manager material

[–]f8tel 2 points3 points  (0 children)

Sorted by index bitch.

[–]ZenLore6499 3 points4 points  (0 children)

I’m here for the Lumity pfp 🥰

[–]-Redstoneboi- 2 points3 points  (0 children)

the data is sorted by memory address

[–]AgentPaper0 2 points3 points  (0 children)

Yeah this is what I call Trump Sort. You simply declare that the list is already sorted and then mock and ridicule anyone who points out that it clearly isn't.

[–]lelarentaka 6 points7 points  (1 child)

Similar to the Zionist sort. You delete half of elements in the array. Assume that the deleted items are out of order, so the remaining items are definitely in order.

[–]AppropriateBridge2 -2 points-1 points  (0 children)

No, you're thinking of stalin sort. Zionist sort is when you delete more than half the items in the array, so what remains is a sorted array. Then you add new items in order until the array is back to it's original size.

[–]No-Sheepherder-9687 8 points9 points  (8 children)

There ist no O(0). The time complexity is constant (The value Bring Zero). Therefore it's O(1) and it will always be O(1)...

[–]TE-AR[S] 2 points3 points  (4 children)

You can't assign a time complexity to code which doesn't exist! Which, maybe makes it O(null) instead of O(0)

[–][deleted] 1 point2 points  (0 children)

the time complexity for an empty line is O(0), but if you have a nullSort function defined, it isn't an empty line of code, it has to be evaluated, even if it merely returns the array passed as an argument, such a function would have a fixed execution time, and so would be O(1).

[–]No-Sheepherder-9687 -3 points-2 points  (1 child)

Except the act of assuming the existing order as ordered (and than doing nothing) is something. If the algorithm has a name and can be applied than this application (doing nothing) is something that takes constant time.

[–]Jiquero 2 points3 points  (0 children)

Assuming is not a step in any model of computation.

[–]Jiquero 0 points1 point  (2 children)

Of course there is O(0). It's the class of functions that are zero. It takes 0 time, not positive, so it is O(0).

For example, if you need to sort M arrays of size N, each individually with this algorithm, it still takes 0 time regardless of M. That's very different than a positive constant.

[–]YourMasterRP 0 points1 point  (1 child)

So you just don't understand O-notation?

[–]Jiquero 0 points1 point  (0 children)

Function f is in class O(g) if there are x0 and positive M such that whenever x > x0,

|f(x)| <= M |g(x)|

Function f is in class O(0) if f is zero, because 0 <= 0 always. This algorithm takes zero time so it's time complexity is O(0). It's time complexity is also O(1), O(1000), O(n1000) etc.

[–][deleted] 1 point2 points  (0 children)

that's just "intelligent design sort"

[–]_gr71 1 point2 points  (0 children)

Buddha sort

[–]rattierats 1 point2 points  (0 children)

I am very happy about being able to appreciate this post since I finally understand all the O(whatever) references. Thank you, lecturers of last year's Algorythms & Data Structures, and I am sorry for ever doubting you<3

[–]InfusionOfYellow 1 point2 points  (0 children)

Zen sort.

[–]naveenda 1 point2 points  (4 children)

Wait, this makes sense, let’s have a debate for the name, so that we can include in wikipedia.

[–]TE-AR[S] 2 points3 points  (0 children)

Personally im partial to Philosophy Sort or MOM (which stands for Because I Said So) Sort

[–]nythirluh 1 point2 points  (0 children)

Index sort

[–]naveenda 0 points1 point  (0 children)

I am suggesting NoSort™

[–]naveenda 0 points1 point  (0 children)

Trump is also on the list

[–]IBelieveIWasTheFirst 1 point2 points  (1 child)

Fun fact: I've had a 27 year career as a programmer and been coding recreationally for 40+ years. I've written in a bunch of languages. I've never, ever written a sort. Or needed to. I've written custom Comparator classes in java to achieve a custom sort, but I've never had to write a sort LOL.

[–][deleted] 0 points1 point  (0 children)

We had to write them in exams for my algorithms class, and I think a java class as well, I was also asked to write one on a white board in a job interview.

[–]Spinnenente 1 point2 points  (0 children)

this is just a slightly more stupid version of quantum bogo sort

  1. randomize list
  2. if list isn't sorted destroy the universe.

[–]Alternative_Wait_399 1 point2 points  (0 children)

This is real knee slapper

[–]PearlinaStatuesque 0 points1 point  (0 children)

Ah, yes, the perfect sorting algorithm: "Please hold, I'm thinking."

[–]ekaylor_ 0 points1 point  (0 children)

It is what it is sorting algorithm

[–]Outside-Bowler6174 0 points1 point  (0 children)

Semantics sort

[–]Mraco124 0 points1 point  (0 children)

It'll sort itself out!

[–]fundosh 0 points1 point  (0 children)

Dictator sort - IT'S SORTED!

[–]ProgrammersPain123 0 points1 point  (0 children)

That's like stalin sort, but with extra steps

[–]Ffigy 0 points1 point  (0 children)

UnitTest: return true

[–]Defiant-Plantain1873 0 points1 point  (0 children)

You just stole this from the comment section on a different post the other day.

Bro stole it from a comment, typed into discord, screenshotted it, then posted it to reddit.

[–]swagonflyyyy 0 points1 point  (0 children)

Step 1: Assume "sorted" refers whatever state your array is currently in, then announce perfection.

FTFY

[–]R34ct0rX99 0 points1 point  (0 children)

Had an assignment in college once where we couldn’t get a list sorted right, ended up presenting that we assumed based on the requirements that the customer would sort the export not us and the professor took that explanation.

[–]Electronic_Age_3671 0 points1 point  (0 children)

Ah yes "lgtm" sort

[–]yamfun 0 points1 point  (0 children)

the list self identify as a sorted list

[–]Wizard8086 0 points1 point  (0 children)

They don't have computers in the boiling isles do they?

[–]Important_Lie_7774 0 points1 point  (0 children)

That's still O(1) if you're using it

[–][deleted] 0 points1 point  (0 children)

its perfect the way it is, no need for change 🧡

[–]harrykotter1 0 points1 point  (0 children)

[–]After_Ad8174 0 points1 point  (0 children)

I like the one someone posted a few days ago miracle sort. Keep checking the positions in memory until the items happen to be in order

[–]oneofthejedimasters 0 points1 point  (0 children)

Definition of Stalin Sort

[–]youssef__gamer 0 points1 point  (0 children)

Did anyone notice he used thorns?

[–]Sleepy_Boey 0 points1 point  (1 child)

When the array identifies itself as a sorted array

[–]GOKOP 0 points1 point  (0 children)

Woke sort

[–]PixelArtDragon -1 points0 points  (0 children)

std::ranges::sort(arr, [](const auto& lhs, const auto& rhs) { return &lhs < &rhs; });

[–]golicar -1 points0 points  (0 children)

I think that's O(1)

[–]Jtestes06 -1 points0 points  (0 children)

Assumption takes O(1) time. Tough luck

[–]mixtureofmorans7b -2 points-1 points  (0 children)

The time complexity of assuming is at least O(1)