The Fastest Way to Sort Anything, Like a Programmer. Idea of the day #451

preview_player
Показать описание
Divide and Conquer, like a programmer.

If I gave you a deck of cards and asked you to sort them from low to high card, how would you do it? Most non-programmers fan out the cards and proceed to move cards forward and back until things finally come together. While that will get the job done, it's not the fastest way to do it.

What programmers do is try to split whatever we're trying to sort into smaller sections, then sort each section one by one, and finally merge the sections at the end. For example, by splitting a deck of cards into two piles of 26, or 4 piles of 13, each of the piles will take a fraction of the time to sort because you'll be doing fewer comparisons to determine the positions of each individual card.

Merging the piles at the end is a breeze... it's sort of like playing solitaire. Once you've sorted all the stacks at the bottom, it takes seconds to merge them into the 4 stacks at the end.

This method works for sorting just about anything.

This was featured as the June 6, 2017 Idea Of The Day.

I post a new idea each day on my Idea of the Day Blog. Some don't suck.

#ideaoftheday #vlog
#iotd #sorting #productivity #tip
Рекомендации по теме