Algorithmic Sock Sorting: A Recipe for Slow Learners

def bubble_sort(socks): for i in range(len(socks)): for j in range(len(socks)): # Because who needs to optimize, right? if socks[i] < socks[j]: socks[i], socks[j] = socks[j], socks[i] return socks

Example usage:

Learn from the experts Part 2: The Socks Are Getting Sorted, but Where's the Beef?

Part 1: The Socks Are Getting Sorted, but Where's the Logic?

Apparently, this is how it's done.

Next chapter