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.

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…
The 11 best Father’s Day deals that you can get for Sunday
Data from a workout showing on the screen of the Apple Watch Series 8.

Father's Day is fast approaching and there's still time to buy your beloved Dad a sweet new device to show him how much you love him. That's why we've rounded up the ten best Father's Day tech deals going on right now. There's something for most budgets here, including if you're able to spend a lot on your loved one. Read on while we take you through the highlights and remember to order fast so you don't miss out on the big day.
Samsung Galaxy Tab A8 -- $200, was $230

While it's the Plus version of the Samsung Galaxy Tab A8 that features in our look at the best tablets, the standard variety is still worth checking out. Saving your Dad the need to dig out their laptop or squint at a small phone screen, the Samsung Galaxy Tab A8 offers a large 10.5-inch LCD display and all the useful features you would expect. 128GB of storage means plenty of room for all your Dad's favorite apps as well as games too. A long-lasting battery and fast charging save him the need for a power source too often too.

Read more
The Apollo wearable is proven to help you sleep better (and it’s on sale)
Apollo wearable worn during sleep in bed.

This content was produced in partnership with Apollo Neuro.
Stress, anxiety, and insomnia are all concerning things that just about everyone struggles with at one time or another. Maybe you can sleep, fending off insomnia, but you lack quality sleep and don’t feel rested in the morning. Or, maybe when it’s time to kick back and relax, you just can’t find a way to do so. There are many solutions for these issues, some work, and others don’t, but one unlikely area of support can be found in a modern, smart wearable.

Medicine is the obvious choice, but not everyone prefers to go that route. There is an answer in modern technology or rather a modern wearable device. One such device is the Apollo wearable, which improves sleep and stress relief via touch therapy. According to Apollo Neuro, the company behind the device, which is worn on your ankle, wrist or clipped to your clothing, it sends out waves of vibrations to help your body relax and reduce feelings of stress. It's an interesting new approach to a common problem that has typically been resolved via medicine, therapy, or other more invasive and time-consuming techniques. The way it utilizes those vibrations, uniquely placed and administered, to create a sense of peace, makes us ask, can it really cure what ails us? We’ll dig a little deeper into how it achieves what it does and what methods it’s using to make you feel better.

Read more
What comes after Webb? NASA’s next-generation planet-hunting telescope
An illustration shows how NASA's Habitable Worlds Observatory would measure the atmosphere of distant planets.

When it comes to building enormous, complex space telescopes, agencies like NASA have to plan far in advance. Even though the James Webb Space Telescope only launched recently, astronomers are already busy thinking about what will come after Webb — and they've got ambitious plans.

The big plan for the next decades of astronomy research is to find habitable planets, and maybe even to search for signs of life beyond Earth. That's the lofty goal of the Habitable Worlds Observatory, a space telescope currently in the planning phase that is aimed at discovering 25 Earth-like planets around sun-like stars.

Read more