Computer drawing in air, showing the earth, with the words Drew's website on top

HomeProjectsWritingBookPublicationsPresentationsEvents

CHEEREIOMusicGamesEphemeraCV

GithubNewsletterDatasetsGoogle Scholar

One randomly-generated sorting algorithm, please!

Do you have an unsorted list of N natural numbers? Do you just hate it when programs are guaranteed to terminate? Do you get angry when algorithms do better than factorial time? Then you're in luck! The following algorithm has been generated just for you:

  1. Begin with a gaslighting strategy. Insist to everyone that the list is already in order, even if it is not. If they give up arguing with you, terminate the program. If they insist that you actually sort the list, proceed to the next step.
  2. Uh oh! You've triggered a penalty step. Before you proceed, you must perform a task. Obtain one (1) chess grandmaster. You are generous, so you let them go first. After they move their piece, move a random one of yours to a random cell on the board. If this move violates the rules of chess, flip the board in anger and start again. If it is a legal move, continue playing until either the board is flipped or checkmate. If the grandmaster has won, repeat the game. If you won, proceed to the next step. You've paid the penalty.
  3. You turn to mathematical ecology for inspiration. For each number in your list, generate a population of rabbits proportional to the number and a population of wolves inversely proportional to the number. Wait for each system to equilibrate. Read off the equilibrium population of rabbits in order of population size, printing the number corresponding to each.

Congratulations! Your list is now sorted. Click here to return to the front page, where more randomly-generated algorithms await.