Round up all socks in the washing machine and separate them into two piles. One pile for the dots and one pile for the non-dots.
Use a sieve of Eratosthenes to filter out any socks that don't fit into either category.
Take the pile of dots and sort them by pattern. This is the most crucial step.
Use a modified version of the Ford-Fulkerson algorithm to ensure that all dots are in their correct order.
Once all socks are sorted, store them in a neat and tidy drawer, separated by category.
Label each category with a barcode for easy identification.