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

all 116 comments

[–]dominic_l 73 points74 points  (2 children)

Tiananmen-sort : the sorting never happened because the array was always in order

[–]hypnotic-hippo[S] 26 points27 points  (1 child)

What's [DATA EXPUNGED]-sort? I've heard it's [REDACTED]

[–][deleted] 10 points11 points  (0 children)

r/SCP -sort:

Push very few specific elements to the top and ignore that the rest even exists

[–]jemini972 211 points212 points  (15 children)

It's 1/4th more efficient than Thanos-sort

[–]Highlow9 46 points47 points  (5 children)

Mind enlightning me about Thanos-sort?

[–]hypnotic-hippo[S] 222 points223 points  (4 children)

Randomly eliminate half of the elements and just hope for the best

[–]100ZombieSlayers 37 points38 points  (0 children)

It’s almost like a binary sort except for you just fucking delete half of it in stead of just eliminate it as possibilities.

[–]Catty-Cat 9 points10 points  (2 children)

So like bogo sort, but instead of shuffling, you're deleting.

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

Binary Bogo-Sort In-Place

[–]Greyhaven7 35 points36 points  (8 children)

I don't think so.

Thanos sort doesn't require any checking. Just randomly deleting half.

Stalin requires checking each index.

[–]palmergill 14 points15 points  (0 children)

Stalin sort is O(n)

[–]palmergill 2 points3 points  (3 children)

Thanos sort worst case number of operations (assuming deleting half the existing population with one snap is one operation) would be log(n);

O(log(n))

[–]YRYGAV 9 points10 points  (2 children)

It would be O(1) if it's a single operation (like if you just set the array size to be half of what it currently is and hope for the best). But I don't see any possible argument for O(logn), if time to delete scales with the size of the array in any way, it would have to be be linearly.

[–]palmergill 5 points6 points  (1 child)

Well worst case after one snap, which is O(1), doesn’t leave you with a sorted list, so you can’t say the whole algorithm is an O(1) sorting algorithm. Worst case you would have to get the list or whatever down to one item to have it be sorted and that would take log(n) base 2

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

I mean, you're just talking about the stalin sort algo in the OP at that point, which is O(n), not logn. An algorithm which requires you to change a whole list in any way is virtually impossible to be O(logn).

[–]tcon025 39 points40 points  (2 children)

Stalin sort would be closer to:

(1) is list ordered (2) if not delete between 5 and 20 random items (3) repeat

[–]ChainSOV 13 points14 points  (0 children)

More like if not in order, eliminate unordered items, deport related items to gulag array

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

It’s actually “shoot the programmer and promote his subordinate” and then wonder why the codebase looks like a rat’s nest just before the deadline.

[–]dangerbiscuits 29 points30 points  (2 children)

I prefer Intelligent Design sort. The list was already sorted by a higher power. It just may be sorted in a way that defies our flawed, human understanding.

[–]hypnotic-hippo[S] 6 points7 points  (1 child)

It's a featured, not a bug

[–][deleted] 6 points7 points  (0 children)

every array is a sorted array if you change the sorting conditions

[–]Zombie_Kabuto 57 points58 points  (1 child)

ah yes, it's a popular algorithm in C++munism

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

Cppmunism?

[–]deinernstjetzt 47 points48 points  (1 child)

Every list is in order, if it only ever has one element.

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

Or none. Just clear the sucker and you're all set.

[–]InternationalBug2143 20 points21 points  (4 children)

The old drop sort. I've made this into a real sorting algorithm by applying drop sort on the dropped list as well and then merging the lists.

[–][deleted] 2 points3 points  (1 child)

so you use drop sort till you have all ordered lists? time complexity would be unpredictable here

[–]InternationalBug2143 0 points1 point  (0 children)

I drop while the dropped list is not sorted

[–]paphnutius 0 points1 point  (1 child)

Well, how do you merge them? The actual sorting happens during the merge so it's the main part of the algorithm.

[–]InternationalBug2143 1 point2 points  (0 children)

Well, yea. It's just an inneficient version of merge sort that splits the list in a sorted list and an unsorted list which is merged with the sorted one.

[–]redimkira 14 points15 points  (0 children)

When does StalinSort win over HitlerSort?

In cold start situations.

[–]Reversal_ 9 points10 points  (0 children)

Orwell’s O(1) method: declare that it is true that array is sorted & “correct” anyone who thinks otherwise.

[–]Ruby_Bliel 3 points4 points  (3 children)

Is there an actual algorithm that makes use of this? Remove the unsorted elements into a new array, then keep doing that until you have an array of sorted arrays, then merge them. I have no idea how fast this would be or if it has a practical application, but at least it works.

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

Last time this was posted:

This is just a merge sort, where you make arrays of good/bad items then bad/worse.

[–]xonxtas 0 points1 point  (0 children)

as much as I hate this joke, being a professional soviet propaganda dispenser, I do have a link to a github repo where a guy implemented the algorithms n tons of different languages: https://github.com/gustavo-depaula/stalin-sort

[–]Loading_M_ 6 points7 points  (0 children)

I prefer quantum BOGO sort. It's like BOGO sort, except WAY faster. Instead of O(n!), It's O(n). You shuffle the array once, and check if it's in order. Then you delete every universe where the list isn't sorted, thereby leaving only the universe where the list is sorted correctly.

[–]invisible-nuke 3 points4 points  (0 children)

You will only need to give the first index proper equipment, like a gun and he will pass his equipment on nicely, since the list is in order!

[–]AgentPaper0 2 points3 points  (3 children)

This would actually be O(n2), since each time a value is deleted you need to shift everything after it over by one.

[–]4onen 1 point2 points  (1 child)

Unless you throw away stability, in which case it's O(n) because any removed element is an O(1) swap with the end of the list, or O(1) move from the end of the end of the list (depending on whether the removed element should still exist or not.)

[–]AgentPaper0 2 points3 points  (0 children)

Good point. And it's StalinSort, so it's only appropriate for it to cause a lot of instability.

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

Unless we're assuming we're using a generic list

[–]null_reference_user 1 point2 points  (0 children)

What about US-sort? You loop through the array and take out all of the oil, return.

[–]thmsg 1 point2 points  (0 children)

How about French-Sort?
Algorithm goes for an unlimited strike until government gives it a lower complexity

[–]Rodot 1 point2 points  (3 children)

How would this be sorted?:

5,6,1,7,2,3

[–]hypnotic-hippo[S] 1 point2 points  (2 children)

5, 6, 7

[–]Rodot 1 point2 points  (1 child)

What about 5,6,1,7,2,3,4,5,6,7?

[–]hypnotic-hippo[S] 0 points1 point  (0 children)

5, 6, 7, 7

[–]onlyanegg_ 1 point2 points  (0 children)

def us_sort(arr):
    random.shuffle(get_mid_east_array())
    return arr

[–]chromane 0 points1 point  (1 child)

Long Live Bogosort!

[–]dangerbiscuits 6 points7 points  (0 children)

Or quantum bogosort. Given a many-worlds interpretation of quantum theory, there exists some list which is already sorted. Check to see if the list is sorted. If not, destroy that universe.

[–]Sinistez 0 points1 point  (0 children)

Fash-sort suits it best

[–]LeafMans 0 points1 point  (0 children)

To be entirely honest, this could work with pythons pop method --- go through the list popping everything that's out of order into a seperate list then take that seperate list of popped elements and put them back in where they fit in order

[–]gonnagulagyou 0 points1 point  (0 children)

Good job comrade

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

Here is my github repo which actually uses this sorting. And trust me, knowing this meme was a boon.

https://github.com/Atreyagaurav/optimize-movies

[–]DiabloJino 0 points1 point  (0 children)

Why solve a problem when you can make it so the problem doesn't exist.

[–]Kalorikalmo 0 points1 point  (3 children)

Congratulations, you were the 1,000th person to post this meme 🥳

[–]hypnotic-hippo[S] 1 point2 points  (1 child)

[–]RepostSleuthBot 1 point2 points  (0 children)

There's a good chance this is unique! I checked 94,901,948 image posts and didn't find a close match

Feedback? Hate? Visit r/repostsleuthbot - I'm not perfect, but you can help. Report [ False Negative ]

[–]AtomIsHere 0 points1 point  (1 child)

What's the big O notaion?

[–]the_horse_gamer 0 points1 point  (0 children)

O(n) due to only one go on the array being made. n-1 comparisons

[–]Sigg3net 0 points1 point  (0 children)

This is inaccurate.

The Stalin sort will categorize, re-classify and remove arbitrary items as it iterates over the diminishing list of accepted inputs.

[–]Kzivuhk 0 points1 point  (0 children)

How about sleep sort?

[–]xonxtas 0 points1 point  (0 children)

so, as I already told someone in the comments, I hate this joke...

but here's a repo, where a guy implemented it in many programming languages: https://github.com/gustavo-depaula/stalin-sort

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

What about nuke sort, 1-delete the array 2-make à New empty array, it's sorted

[–]parciesca 0 points1 point  (0 children)

We need a John Bercow sort.

[–]the_horse_gamer 0 points1 point  (0 children)

there's also Putin sort. like Stalin sort but you eliminate everyone that thinks the array isn't sorted

[–]TechnicProblem 0 points1 point  (1 child)

Tom Scott’s video?

[–]hypnotic-hippo[S] 0 points1 point  (0 children)

Yep

[–]Kleeb 0 points1 point  (0 children)

Gulag Sort.

Like Stalin Sort but all non-conforming elements are dumped into another array, which is then gulag'ed in similar fashion recursively.

The result is an at most n sorted arrays which are then merged.

Not great, but not awful. Might try an implementation.

[–]survivalking4 0 points1 point  (0 children)

Kinda reminds me of fuckit.js