Bogo Sort Bot is a program that shuffles randomly generated number sets for all eternity and emails a list of subscribers whenever it succesfully sorts a number set.
Sorting Algorithms: A Neccesity of the Modern Era
Sorting algorithms are one of the first topics a computer scientist learns about. Why? Data is constantly being fed into software to be analyzed. In the twenty-first century, companies across all industries depend on data analysis to figure out how to market whatever it is that they're selling.
From an advertising perspective, every click you make online can be attributed to an identity representing you as user. This data can be compiled to represent you so that whenever they want to show you an ad, they can show you an ad that suits your identity the most, an ad that would most likely compell you to purchase their good or service.
The Sort of Sort that is Bogo Sort
Let's assume a deck of cards can be put in a certain order (across suits, in certain colors, etc). Take a deck of cards, shuffle it around. Is it in order? No? Then shuffle it again. Is it in order now? No!? Well, keep shuffling the deck of cards until it's in order.
Congratulations, you are now a computer, you just performed Bogo Sort on a deck of cards. Need that in pseudo-code, computer-person?
while data is not sorted: shuffle data
Bogosort in Python
# Import the 'random' module, this allows us to # randomly generate numbers with randint(lower,upper), and # shuffle lists with shuffle(list). import random # Generate Data Set of 5 random numbers between 0 and 10 dataSet = [random.randint(0,11) for i in range(5)] # Function returns True if dataSet is sorted, # returns False if not sorted def sorted(dataSet): # Data is determined sorted until proven unsorted isInFactSorted = True for index in range(len(dataSet)-1): # If the next number is EVER less than # the current number, data set is unsorted if dataSet[index] > dataSet[index+1]: isInFactSorted = False return isInFactSorted # Show us what the dataSet looks like originally print("Unsorted: ",dataSet) # Shuffle the dataSet while it's not sorted while not sorted(dataSet): random.shuffle(dataSet) # Show us the sorted dataSet print("Sorted: ",dataSet)