Strangest Sorting Algorithms

Here is a list of the strangest sorting algorithms and some of them are downright hilarious.

1 Sleep Sort

For every element x in an array, start a new program that:

  1. Sleeps for x seconds.
  2. Prints out x.

The clock starts on all the elements at the same time. It works for any array that has non-negative integers.

 

2 Quantum Bogosort

Quantum Bogosort is as follows:

  1. Randomly shuffle the elements of the list.
  2. If the list is not sorted, destroy the universe.
  3. Any surviving universes will then have the sorted version of the list.

Works in O(N) time. This algorithm relies on the accuracy of the many worlds theory of quantum mechanics.

 

3 Random Sort

It is as follows:

  1. Create and compile a random program.
  2. Run the random program on the input array.
  3. If the program produces sorted output, you are done.
  4. Else repeat from the beginning.

 

4 Solar Bitflip Sort

  1. Check if the array is sorted.
  2. If the array is sorted, return the array.
  3. If the array is not sorted, wait for 10 seconds and pray for having bit flips caused by solar radiation, just in the correct order then repeat from step 1.

 

5 Spaghetti Sort

  1. Convert the data to positive real values scaled to the length of a piece of spaghetti.
  2. Write each value onto a piece of spaghetti (a spaghetto) and break the spaghetti to the length equal to the scaled values.
  3. Hold all resulting spaghetti in a bundle and slam the end on a flat surface.
  4. Take the spaghetto which sticks out i.e. the longest one, read the value, convert back to the original value and write this down.
  5. Repeat until all spaghetti are processed.

Works in O(N) time.

 

6 Stalin Sort

  1. Gather up the comrades and show them the list.
  2. Ask the comrades to raise their hands if they believe the list is sorted.
  3. Select any comrade who did not raise his hand, and executes him as a traitor.
  4. Repeat steps 2 and 3 until everyone agrees that the list is sorted.

Usually, works in constant time.

 

7 Bogosort

  1. Randomly, shuffle the array.
  2. Check if it’s in order.
  3. If it’s not in order then reshuffle. Repeat until the array is in order.

 

8 Intelligent Design Sort

Whatever state your list is in, it’s already sorted meaning:

The probability of the original input list being in the exact order it’s in is 1/(n!). There is such a small likelihood of this that it’s clearly absurd to say that this happened by chance, so it must have been consciously put in that order my an intelligent sorted. Therefore it’s safe to assume that it’s already optimally sorted in some way that transcends our naive mortal understanding of ‘ascending order’. Any attempt io change that orders to conform to our own preconceptions would actually make it less sorted.

 

9 The Internet Sort

It’s just a bubble sort, but perform every comparison by searching the internet. For example, “Which is greater – 0.211 or 0.75?”.

 

10 Committee Sort

  1. To sort a list comprised of N natural numbers, start by printing out N copies of the whole list on paper.
  2. Now form N committees from any poor souls who happen to be milling around the office. The number of people on each committe should correspond to their particular value in the list.
  3. Each committee is given their sheet of paper and told to, through a meeting or some other means, decide where in the sorted list their number should fall.
  4. The list will be naturally sorted by the order that the committees return with their results.

 

And here’s a potato.

Image result for coding potato

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s