The Fastest Way to Sort Anything
By
Staten Island, NY Posted: 6/6/2017 1:00:00 AM
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.
Joe Crescenzi, Founder
(Reply N/A) (Edit Topic N/A)
(Like Topic N/A) [0 ] 5309 Views
Related Posts
Productivity(72)Sorting(1)Tips(34)
Top 25 Posts
* Note: The ideas on "Idea of the Day" were posted without any formal research into existing inventions.
In some cases, patents may already exist for these ideas, in other cases, there may not be any existing patents and you are free to develop and explore the viability of developing and patenting the ideas.
The authors make no claim that any of the ideas are safe, practical, or suitable for any particular purpose. You are responsible for the results of trying, developing, patenting or using any of the ideas on this site.
For some people, our ideas are just an interesting read, but our goal is to encourage you to take action. If you see an idea that you like, do something with it... Take action.
- Joe