Order makes finding easy
Why Do We Sort Things?
Sorting costs effort once, then saves effort every single time you look for something.
-
Step 1 of 5
Sorting means putting things in an order.
By size, by colour, by letter, by number. You pick a rule, and then every item has a definite place relative to the others.
-
Step 2 of 5
Finding things in a jumble is slow.
In an unsorted pile of 1,000 items you may have to check all 1,000. On average you check 500.
-
Step 3 of 5
In sorted order you can halve the problem.
Open a dictionary in the middle. Your word is either before or after — so half the book is gone in one look. Repeat and 1,000 items take ten checks.
-
Step 4 of 5
Sorting also reveals things.
Line up a class by height and the tallest, shortest and middle are instantly visible. Order exposes patterns invisible in a jumble.
-
Step 5 of 5
It is worth it when you look more than once.
Sorting takes effort up front. If you only ever need one item, do not bother. If you will search a hundred times, sort first.
Sorting is one of the most studied problems in computing, precisely because so much depends on doing it well.
The short version
Sorting costs effort once and makes every future search dramatically faster.
Try it yourself
Time yourself finding a word in a dictionary, then in a shuffled list of the same words. The difference is the value of order.
Topics