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!

Editors' Recommendations

Luke Dormehl
I'm a UK-based tech writer covering Cool Tech at Digital Trends. I've also written for Fast Company, Wired, the Guardian…
Digital Trends’ Tech For Change CES 2023 Awards
Digital Trends CES 2023 Tech For Change Award Winners Feature

CES is more than just a neon-drenched show-and-tell session for the world’s biggest tech manufacturers. More and more, it’s also a place where companies showcase innovations that could truly make the world a better place — and at CES 2023, this type of tech was on full display. We saw everything from accessibility-minded PS5 controllers to pedal-powered smart desks. But of all the amazing innovations on display this year, these three impressed us the most:

Samsung's Relumino Mode
Across the globe, roughly 300 million people suffer from moderate to severe vision loss, and generally speaking, most TVs don’t take that into account. So in an effort to make television more accessible and enjoyable for those millions of people suffering from impaired vision, Samsung is adding a new picture mode to many of its new TVs.
[CES 2023] Relumino Mode: Innovation for every need | Samsung
Relumino Mode, as it’s called, works by adding a bunch of different visual filters to the picture simultaneously. Outlines of people and objects on screen are highlighted, the contrast and brightness of the overall picture are cranked up, and extra sharpness is applied to everything. The resulting video would likely look strange to people with normal vision, but for folks with low vision, it should look clearer and closer to "normal" than it otherwise would.
Excitingly, since Relumino Mode is ultimately just a clever software trick, this technology could theoretically be pushed out via a software update and installed on millions of existing Samsung TVs -- not just new and recently purchased ones.

Read more
AI turned Breaking Bad into an anime — and it’s terrifying
Split image of Breaking Bad anime characters.

These days, it seems like there's nothing AI programs can't do. Thanks to advancements in artificial intelligence, deepfakes have done digital "face-offs" with Hollywood celebrities in films and TV shows, VFX artists can de-age actors almost instantly, and ChatGPT has learned how to write big-budget screenplays in the blink of an eye. Pretty soon, AI will probably decide who wins at the Oscars.

Within the past year, AI has also been used to generate beautiful works of art in seconds, creating a viral new trend and causing a boon for fan artists everywhere. TikTok user @cyborgism recently broke the internet by posting a clip featuring many AI-generated pictures of Breaking Bad. The theme here is that the characters are depicted as anime characters straight out of the 1980s, and the result is concerning to say the least. Depending on your viewpoint, Breaking Bad AI (my unofficial name for it) shows how technology can either threaten the integrity of original works of art or nurture artistic expression.
What if AI created Breaking Bad as a 1980s anime?
Playing over Metro Boomin's rap remix of the famous "I am the one who knocks" monologue, the video features images of the cast that range from shockingly realistic to full-on exaggerated. The clip currently has over 65,000 likes on TikTok alone, and many other users have shared their thoughts on the art. One user wrote, "Regardless of the repercussions on the entertainment industry, I can't wait for AI to be advanced enough to animate the whole show like this."

Read more
4 simple pieces of tech that helped me run my first marathon
Garmin Forerunner 955 Solar displaying pace information.

The fitness world is littered with opportunities to buy tech aimed at enhancing your physical performance. No matter your sport of choice or personal goals, there's a deep rabbit hole you can go down. It'll cost plenty of money, but the gains can be marginal -- and can honestly just be a distraction from what you should actually be focused on. Running is certainly susceptible to this.

A few months ago, I ran my first-ever marathon. It was an incredible accomplishment I had no idea I'd ever be able to reach, and it's now going to be the first of many I run in my lifetime. And despite my deep-rooted history in tech, and the endless opportunities for being baited into gearing myself up with every last product to help me get through the marathon, I went with a rather simple approach.

Read more