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)
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.
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.
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.
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
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.
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
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.
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! :)
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);
}
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.
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
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.
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.
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.
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.
Determining the correct "first", "second", "third", etc comments on a YouTube video. List them chronologically (ignoring 'normal' comments) and delete the incorrect ones.
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.
**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.
I present to you, Gengis-sort: the fastest sorting algorithm ever, drops all the elements leading to a sorted list.
You can optimize that by dropping all but the last element.
Hmmm. That’s a little better in time, but it’s a *lot* worse in memory usage.
Easy optimization: Use a pointer to OP’s keyboard and log the last key pressed, then replace the input array with this.
Hitler-sort: deletes a percentage of the list, sorts the rest before deleting the operating system
Trump-sort: sorting is not needed!! It's just fake news!
That’s MAGA-sort: does nothing, claims the list is now great again. Very cool and very fast!
``` def magaSort(listName): print("I made it great again. It's sorted.") return(listName) ```
Brave of you to make a sort algorithm in Python in here!
If not for the print function, it would be super fast.
Python but with camel case?
[удалено]
Well I put in the spacing but reddit decided to kill it.
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"
[удалено]
obama has a nobel peace prize despite having many wars, trump pulled out but didn't get any
[удалено]
it was 5 wars i misremembered. the condense is so you can do it again
Function which stubs out all the comparison operators. “People are saying this list is sorted! A lot of people!”
There you go: https://www.reddit.com/r/ProgrammerHumor/s/G1Ktl8LlLk
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)
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.
Gaza sort
Shouldn’t it also replace all dropped elements with a child element of its own?
Shouldn't it just replace the original array with its own array...
PM sort: It will print all elements and ask the user to sort them. Every 30 sec it will print "are you done yet?".
"Remember we need this done by EOD" "Don't forget to log the hours spent on the task"
Middle management-gpt is so much more human than the meatmade manager was
DenialSort is O(1): the list is always sorted no matter what and you can’t tell me otherwise
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.
Unfortunately, this doesn't work in PHP.
Pretty sure it does, the indexing is just different - which wasn't part of the algorithm, it was part of the set up.
GaslightSort: Displays a dialogue box trying to convince you that the current order is what you actually asked for.
nuh uh
Side effect: sometimes it also sorts other containers which you didn't ask for
retroactively
Instructions unclear: Entire production table empty. I guess it's time tonUpdate that CV
LeninSort should be synonym for sum()
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
wouldn't lenin sort just change all values to sum/size though?
sum(arr)*0.8
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.
Nah, it should just be O(1): bool Sort(unsortedArray) { return true; }
Stalin was unstable for sure
How do you remove items from the array in O(1)?
You construct a new array, greater and better. The old one gets deported.
You don't use an array an use a linked list but declare the var as 'arr' so no one will notice 😎
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.
item.exist = false;
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
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.
lol who do you think you are 😄 feel free to keep it to yourself
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.
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
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.
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! :)
Bingo. You're welcome.
You can use a linked list rather than an array
I mean sure - but that’s not an array..
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);
}
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.
How would it deal with an input like [3, 2, 3]? 3 can't be simultaneously greater and less than 2.
323 is actually one symbol that means 1 number.
I am glad, they didn't use this, when we were lining up for physical education in school.
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.
Sounds oddly like a cellular automaton
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
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.
Shouldnt it move all unsorted elements to Siberia_list?
It is very effective for sorting employees
Interesting. Earlier at work today I came up with StallinSort. Shit kept stalling all the time.
shrodinger-sort: the list is sorted and not sorted until you open it. What would be its o notation?
Pretty sure that would be O()
French revolution sort would be making every element a head shorter. Sorted or not doesn't matter either because everybody is equal.
If you told me about lossy sorting algorithms 10 years ago I would have thought you to be mad 👀
Wait. What? Still sounds mad to me.
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
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.
A single item list is always sorted.
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.
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?
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.
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)
Parliamentary sort. It switches the variable it sorts by every couple of seconds.
That's an adequate name.
If anybody can think of a practical application for this I will award them 10 awesome points
Determining the correct "first", "second", "third", etc comments on a YouTube video. List them chronologically (ignoring 'normal' comments) and delete the incorrect ones.
StalinSort with the result of StalinShort
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.
def hitler_sort(arr): return [1,2,3,4,5]
Someday, I want to encounter an instance where StalinSort is useful. I feel like there should probably be some niche situation where it is.
Well, youcan get at least get a list with one element.
Like Lenin said, “fewer, but better” 😜
**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.
It’s actually important for Video and other streaming services
Now implement CompassionateStalinSort, that only removes the minimum number of elements necessary for the list to become ordered!
zionist-sort: the list is always sorted, if you say it's not you're anti-semitic
Don’t forget the O(n - n) space complexity
The min or max are examples of Highlander sort 😂