import yhwh def interventionSort(unsortedList): sortedList = yhwh.pray( "Oh great and merciful Lord above, let thine glory shine upon yonder list!", unsortedList ) return sortedList
I prefer the one where you randomly sorting the array until all elements are in order. ( Bogosort )
And the time complexity is only O(1)
Is it thread safe?
I hear, it actually significantly increases the chance of the miracle occurring when you pass the array into multiple threads. It’s a very mysterious algorithm.
This is the algoritm I use at work.
My favorite is StalinSort. You go through the list and eliminate all elements which are not in line.
you should post this on lemmy.ml
Reminds me of quantum-bogosort: randomize the list; check if it is sorted. If it is, you’re done; otherwise, destroy this universe.
The creation and destruction of universes is left as an exercise to the reader
Instead of destroying the universe, can we destroy prior, failed shuffle/check iterations to retain o(1)? Then we wouldn’t have to reload all of creation into RAM.
Delete prior iterations of the loop in the same timeline? I’m not sure there’s anything in quantum mechanics to permit that…
Guaranteed to sort the list in nearly instantaneous time and with absolutely no downsides that are capable of objecting.
You still have to check that it’s sorted, which is O(n).
We’ll also assume that destroying the universe takes constant time.
We’ll also assume that destroying the universe takes constant time.
Well yeah just delete the pointer to it!
In the universe where the list is sorted, it doesn’t actually matter how long the destruction takes!
It actually takes a few trillion years but its fine because we just stop considering the “failed” universes because they will be gone soon™ anyway.
Eh, trillion is a constant
amortized O(0)
Except you missed a bug in the “check if it’s sorted” code and it ends up destroying every universe.
There’s a bug in it now, that’s why we’re still here.
deleted by creator
What library are you using for that?
In Python you just use
import destroy_universe
is-sorted and a handful of about 300 other npm packages. Cloning the repo and installing takes about 16 hours but after that you’re pretty much good for the rest of eternity
that explains why it took god 7 days to make the universe
We still suffer from the runtime errors that could’ve been caught at compilation time.
Since randomizing the list increases entropy, it could theoretically make your cpu cooler just before it destroys the universe.
// portability
Gave me the giggles. I’ve helped maintain systems where this portable solution would have left everyone better off.
Shameless plug for my sort lib
edit: Looking at my old code it might be time to add typescript, es6 and promises to make it ✨ p r o d u c t i o n r e a d y ✨
CosmicRaySort.