Algorithmic Sock Sorting Tutorial

Sort your socks with the power of code!

Sock Sorcery Episode 1

Watch Sock Sorcery Episode 1: "The Sorting Begins"


			# SockSortingAlgorithm

def sort_socks(socks):
    if len(socks) == 0:
        return []

    # Sort by color
    socks.sort(key=lambda x: x.color)

    # Sort by texture
    socks.sort(key=lambda x: x.texture)

    # Sort by size
    socks.sort(key=lambda x: x.size)

    return socks
		
Next Steps

Want more? Visit our Sock Sorting Videos for more algorithmic awesomeness!