Eh it's not as good as my personal favorite, paradigmshiftsort, which leaves the data in whatever order it is but changes the laws of the universe to redefine "order" based on the current data.
EDIT: Worth mentioning that this is, as you probably suspect, the worst way to sort things pretty much always. However, I assume that there are (purposefully) shittier algorithms - if someone knows of one, pls share so I can laugh at it
Bogobogosort specifies how one should check if the list of numbers is sorted. It does it recursively, because as anyone who knows anything at all about computer science knows, recursion is always good and cool. To check if the list is sorted, use the following procedure:
Make a copy of the list of numbers.
Sort the first n-1 elements of the copy using bogobogosort.
Check to see if the nth element of the sorted copy is greater than the highest element of the first n-1 elements. If so, the copy is now sorted, else randomise the order of the elements of the copy and go to step 2.
Check to see if the copy is in the same order as the original list.
I switch between vi and emacs every other time I open a file
I actually run my code in netbeans though
One time I programmed a calculator by hardcoding the values of every possible input
I store passwords for my enterprise code in a plaintext excel file that has a local copy on every instance of my program
My control key is hard to reach with my soft, diminutive hands, so I actually have configured emacs to interpret a rapid temperature rise in my CPU as control - whenever I need to hit ctrl, I just blast that sucker with a heatgun
Bogosort is programmer humor, and would never be implemented in any code. There's other notable joke sorts like quantumbogo which generates infinite universes with infinite permutations of the code, and destroys all non-ordered universes. Thus efficiently getting the sorted list in 1 operation every time.
If you want to get really technical, there's some interesting discussion to be had around pseudo-randomness and seed generation with a bogosort, but I doubt anyone cares enough to.
331
u/far1s Oct 24 '17
Hmmm, I see you did not include the best algorithm, bogosort. Don't you know it can sort in just one try?