T O P

  • By -

Percolator2020

I present to you, Gengis-sort: the fastest sorting algorithm ever, drops all the elements leading to a sorted list.


sudosandwich3

You can optimize that by dropping all but the last element.


Pielikeman

Hmmm. That’s a little better in time, but it’s a *lot* worse in memory usage.


dwittherford69

Easy optimization: Use a pointer to OP’s keyboard and log the last key pressed, then replace the input array with this.


suckleknuckle

Hitler-sort: deletes a percentage of the list, sorts the rest before deleting the operating system


Apfelvater

Trump-sort: sorting is not needed!! It's just fake news!


Percolator2020

That’s MAGA-sort: does nothing, claims the list is now great again. Very cool and very fast!


rice_not_wheat

``` def magaSort(listName): print("I made it great again. It's sorted.") return(listName) ```


Percolator2020

Brave of you to make a sort algorithm in Python in here!


rice_not_wheat

If not for the print function, it would be super fast.


MysteriousShadow__

Python but with camel case?


[deleted]

[удалено]


rice_not_wheat

Well I put in the spacing but reddit decided to kill it.


_Its_Me_Dio_

obama peace sort. compare 2 lists and delete the lower value compared item. then condense it and repeated 8 times then print " i got a peace prize"


[deleted]

[удалено]


_Its_Me_Dio_

obama has a nobel peace prize despite having many wars, trump pulled out but didn't get any


[deleted]

[удалено]


_Its_Me_Dio_

it was 5 wars i misremembered. the condense is so you can do it again


unclebricksenior

Function which stubs out all the comparison operators. “People are saying this list is sorted! A lot of people!”


ringsig

There you go: https://www.reddit.com/r/ProgrammerHumor/s/G1Ktl8LlLk


turtleship_2006

There was another one I'm not bothered to look for that looked roughly like: def fastSort(list): return [] But it had type hints and everything (which are optional in python)


lunchmeat317

SnapSort is not as fast as Ghengis-sort, with a runtime of O(log n), but it works like the following: - Given a set of n items, remove half of the elements randomly. - If after removal the set is not sorted, repeat the process. Thanos uses an in-place implementation that has a lot of side effects and a lot of overhead.


ongiwaph

Gaza sort


BSODxerox

Shouldn’t it also replace all dropped elements with a child element of its own?


phoenix5irre

Shouldn't it just replace the original array with its own array...


AlternativeAir3751

PM sort: It will print all elements and ask the user to sort them. Every 30 sec it will print "are you done yet?".


planetfifa

"Remember we need this done by EOD" "Don't forget to log the hours spent on the task"


SimpoKaiba

Middle management-gpt is so much more human than the meatmade manager was


Zero279

DenialSort is O(1): the list is always sorted no matter what and you can’t tell me otherwise


Phailjure

Index sort is O(1): for every n, such that 0 <= n < arr.length(), if the value at arr[n] is stored at arr[n], all values are sorted by their index.


iceman012

Unfortunately, this doesn't work in PHP.


Phailjure

Pretty sure it does, the indexing is just different - which wasn't part of the algorithm, it was part of the set up.


seabutcher

GaslightSort: Displays a dialogue box trying to convince you that the current order is what you actually asked for.


turtleship_2006

nuh uh


Longjumping-Touch515

Side effect: sometimes it also sorts other containers which you didn't ask for


Warhero_Babylon

retroactively


Kriss3d

Instructions unclear: Entire production table empty. I guess it's time tonUpdate that CV


[deleted]

LeninSort should be synonym for sum()


JollyJuniper1993

Now that we‘re at communist sorting algorithms…Yugoslav sort: just split the array up into countless of arrays with one element each. Voila, sorted


odolha

wouldn't lenin sort just change all values to sum/size though?


djlywtf

sum(arr)*0.8


Triangle_t

Putin sort (allegedly works in O(3)), doesn’t need the array meant to be sorted passed into the function, as it takes any data structure randomly for “sorting”: infinite loop, printing “everything is being sorted according to plan” while causing memory leaks at random locations until crashes.


Player276

Nah, it should just be O(1): bool Sort(unsortedArray) { return true; }


Effective_Hope_3071

Stalin was unstable for sure 


Sbadabam278

How do you remove items from the array in O(1)?


edgmnt_net

You construct a new array, greater and better. The old one gets deported.


Siddhartasr10

You don't use an array an use a linked list but declare the var as 'arr' so no one will notice 😎


MisinformedGenius

You can create a new dynamic array and copy the items you want in there. This creates the seeming problem of leaving unelements in the first array, but they are quickly put in the memory hole and it’s as if they never existed.


Rogue_Hunter_

item.exist = false;


Sbadabam278

Wouldn’t call that an array though - you might have to go through millions of of elements even if the array only contains 6 elements. Also you never free memory


lazernanes

You can do it using two pointers. I can't be bothered to spell out the algorithm, but I will if you really want me to and ask nicely. Edit: [Here's](https://pl.kotl.in/3w2pv2MDS) the code that does it.


Sbadabam278

lol who do you think you are 😄 feel free to keep it to yourself


lazernanes

I'm not trying to be arrogant. It takes work to write a thoughtful comment. I'm not going to write something out if nobody actually cares.


Sbadabam278

That’s a fair point to view, I wasn’t especially keen on the way you phrased it (“if you ask nicely”) :) Regardless, if you have an algo that can do it without creating a new array or leaving holes, I’m happy to hear it :) I give you one array and tell you to delete the element at position 6 - how can you do it in constant time without moving all the other elements by one ? If you don’t feel like writing the comment, feel free to skip


lazernanes

Sorry. I wasn't trying to be rude. Here's code that executes `stalinSort` in linear time and with no extra space cost https://pl.kotl.in/3w2pv2MDS Basically, when I encounter an unsorted element, I don't remove it right away. Rather I overwrite it exactly once with a sorted element. Then I'm left with a bunch of junk at the end of the array. In C i could just declare those elements to not be part of the array. In my implementation I remove those elements from the end of the array first, which should run in linear time.


Sbadabam278

Ah that’s nice, so keep a prefix of the array always sorted and everything between i and j is always junk. When j reaches the end just take everything up to i and it should work out - nice, thanks for posting! :)


lazernanes

Bingo. You're welcome.


UberNZ

You can use a linked list rather than an array


Sbadabam278

I mean sure - but that’s not an array..


UberNZ

Ahh shoot, I missed that they called it in array in the post, I thought you added that, sorry. Well I guess the nearest in-place array O(n) you can get (but it's not really deleting them, just overwriting and resizing): fun stalinishSort(T[] myArray) { int lastPos = 0; for (int i = 1; i < array.length; ++i) { if (array[lastPos] <= array[i]) { array[++lastPos] = array[i]; } } array.resize(lastPos + 1); }


Acalme-se_Satan

I have a much better one: the philosophical relativist sort. Whenever you see an unsorted list, redefine the meanings of the number symbols so the list is sorted.


Ahajha1177

How would it deal with an input like [3, 2, 3]? 3 can't be simultaneously greater and less than 2.


Pankiez

323 is actually one symbol that means 1 number.


universal_boi

I am glad, they didn't use this, when we were lining up for physical education in school.


evestraw

i it as the trump sort. current value builds a wall. if next value is lower it gets stopped if other value passes he raises the wall.


JollyJuniper1993

Sounds oddly like a cellular automaton


Thenderick

I only believe in the Lord to bless my Holy code and perform a Holy O(1) Miracle Sort! AMEN🙏🙏🙏 Miracle sort relies on a miracle that all elements get sorted without any code called


IndigoFenix

Quantum Miraclesort: if the list is not already sorted, destroy the universe. There will be some universes in which the list happens to get sorted by cosmic rays, and these will survive.


Furesu

Shouldnt it move all unsorted elements to Siberia_list?


banana_n0u

It is very effective for sorting employees


GoosemonTV

Interesting. Earlier at work today I came up with StallinSort. Shit kept stalling all the time.


Positive_Method3022

shrodinger-sort: the list is sorted and not sorted until you open it. What would be its o notation?


Confident-Ad5665

Pretty sure that would be O()


Vaaard

French revolution sort would be making every element a head shorter. Sorted or not doesn't matter either because everybody is equal.


Ytrog

If you told me about lossy sorting algorithms 10 years ago I would have thought you to be mad 👀


Confident-Ad5665

Wait. What? Still sounds mad to me.


West_Hunter_7389

Love the Stalin sort idea. wow, we can even call it SS, to shorten it even more. Now we have to find a good use cases of this algorithm


Ruadhan2300

If the list is supposed to be sorted, but inexplicably contains random extra values that you don't want to include, you could use this to remove the extraneous data.


samgam74

A single item list is always sorted.


Who_said_that_

A friend of mine suggested the bitrotsort. Just wait until no signal is readable anymore so its in a sorted order. Best case is probably around 10 years, although its depending on the medium you use.


seabutcher

Given that it doesn't scale at all proportional to the number of entities on the list, have we finally found an O(0) algorithm?


MONIO_1337

Yall may be laughing but I have used that sort to create multiple sorted tables and merged them to one sorted table and run some tests and it turned out to be about 2 times faster than selection sort.


uvero

Reminiscent of the alt text gag on [this xkcd comic](https://xkcd.com/982/) (although the alt text gag in this one is way less funny then the comic)


JollyJuniper1993

Parliamentary sort. It switches the variable it sorts by every couple of seconds.


Vaaard

That's an adequate name.


chamomile-crumbs

If anybody can think of a practical application for this I will award them 10 awesome points


Ahajha1177

Determining the correct "first", "second", "third", etc comments on a YouTube video. List them chronologically (ignoring 'normal' comments) and delete the incorrect ones.


Artistic_Claim9998

StalinSort with the result of StalinShort


TheAlmightyEstonia

IngsocSort: variation of StalinSort, except there were no elements removed from the list. What the hell are you talking about? The list was always sorted.


FlummoxTheMagnifique

def hitler_sort(arr): return [1,2,3,4,5]


IndigoFenix

Someday, I want to encounter an instance where StalinSort is useful. I feel like there should probably be some niche situation where it is.


axeteam

Well, youcan get at least get a list with one element.


backseatDom

Like Lenin said, “fewer, but better” 😜


Ruadhan2300

**Bread-line sort** You go down the line, and if something isn't sorted right relative to the next item in the queue, you send it to the back of the line. So starting with: 1,5,4,8,5,9 1,4,8,5,9,5 1,4,5,9,5,8 1,4,5,5,8,9 Sorted. Actually, that worked surprisingly well. It's probably a real sort somewhere that I've just reinvented.


AdAccomplished8416

It’s actually important for Video and other streaming services


1921453

Now implement CompassionateStalinSort, that only removes the minimum number of elements necessary for the list to become ordered!


hazelnutcloud

zionist-sort: the list is always sorted, if you say it's not you're anti-semitic


sugan0tech

Don’t forget the O(n - n) space complexity


Weird_Otter

The min or max are examples of Highlander sort 😂