In this video from the TED-Ed YouTube channel, software engineer and educator Chand John explains how a simple sorting algorithm can get your bookshelf organised in no time. It’s called “QuickSort,” and it’s used by programmers in all kinds of applications. Online stores use it to sort items by price, and GPS maps use it to show you the nearest gas stations.
Start by pulling one book from the center of your shelf. This is your partition book. Compare every book on the shelf to your partition book, then place every book that goes before it on the left, and every book that goes after it on the right.
Now select another partition book in the middle of each partition and go through the same sorting process as shown in the video. You should be left with books all fairly close to where they need to be, and you can sort the rest with only a few swaps. Of course, if you’re not into alphabetising, there are other ways to plan out your bookshelves.