Skip to main content

The ultimate sorting algorithm for alphabetizing your books efficiently

What's the fastest way to alphabetize your bookshelf? - Chand John
We’re suckers for the kind of “life hacks” that tell you that you’ve been doing some relatively mundane task all wrong, and that there’s a super-easy alternative which can massively speed up your ability to perform it.
Recommended Videos

That’s what a new video from the TED-Ed YouTube channel does, by showing how different sorting algorithms can transform our ability to quickly alphabetize a large number of books on a bookshelf.

The video starts by describing two common sorting algorithms; “bubble sort” and “insertion sort.” In the former, a sorting algorithm repeatedly steps through a list that needs to be sorted, compares each pair of adjacent items in turn, and then swaps them over if they happen to be in the wrong order. In the latter, new items are constantly “inserted” into previous sublists for an ever-growing search pile.

Both will work for this problem, but are less than efficient if time is of the essence.

The optimal answer, it turns out, is something called “quicksort,” which is regularly used by programmers for a variety of different applications — from sorting items by price to showing you the closest gas station on a GPS map.

To sort your pile of books the quicksort way, begin by taking a book from roughly the middle of the shelf. This becomes your “partition” book, and by sorting everything on its left and right into books which come either before or after it, you instantly reduce the total number of items to search against in sub-piles.

Once this is done, you then add partition books to the middle section of the two smaller piles, and then keep doing this until you have multiple partition books and a bunch of manageable piles to sort. After that, switch to a sorting algorithm like “insertion sort” to get them properly alphabetized.

Simple, right? Sure, it’s a pretty basic bit of computer science translated into the real world, but we bet that you’ll never think about alphabetizing in quite the same way again.

Now if we could only stop spending hours watching such “life hack” videos, we might actually get something done a bit more efficiently around here!

Luke Dormehl
Former Digital Trends Contributor
I'm a UK-based tech writer covering Cool Tech at Digital Trends. I've also written for Fast Company, Wired, the Guardian…
Mazda confirms a hybrid CX-5 and electric SUV are on the way
mazda hybrid cx 5 electric suv 2024 arata concept 4

Mazda might be making headway in the pursuit of bringing back an electric vehicle (EV) stateside.

Ever since it discontinued the MX-30 EV in the U.S. last year, the Japanese automaker has had zero EV offerings for potential U.S. customers.

Read more
Range Rover’s first electric SUV has 48,000 pre-orders
Land Rover Range Rover Velar SVAutobiography Dynamic Edition

Range Rover, the brand made famous for its British-styled, luxury, all-terrain SUVs, is keen to show it means business about going electric.

And, according to the most recent investor presentation by parent company JLR, that’s all because Range Rover fans are showing the way. Not only was demand for Range Rover’s hybrid vehicles up 29% in the last six months, but customers are buying hybrids “as a stepping stone towards battery electric vehicles,” the company says.

Read more
BYD’s cheap EVs might remain out of Canada too
BYD Han

With Chinese-made electric vehicles facing stiff tariffs in both Europe and America, a stirring question for EV drivers has started to arise: Can the race to make EVs more affordable continue if the world leader is kept out of the race?

China’s BYD, recognized as a global leader in terms of affordability, had to backtrack on plans to reach the U.S. market after the Biden administration in May imposed 100% tariffs on EVs made in China.

Read more