What is sorting, and why do we do it?
Humans like to categorise and order things, to greater or lesser degrees.
If you walk into a kitchen, the chances are that you will find there is a drawer set aside for utensils, a cupboard shelf for cups, and another shelf for glasses. There might be a cupboard for plates and bowls, and a separate one for frying pans and saucepans.
Have a look at a bookshelf. Maybe the books are displayed randomly, but often they’ll be organised; maybe by size, by author, by subject matter, or alphabetically by title.
Think about the last time you walked into a supermarket. The fresh vegetables and fruit will have been placed together, bakery goods somewhere else in the shop, tinned good in another aisle. Then there will be a further organisation after that, with all the apples being in the same area, but with each variety of apple occupying its own smaller space within that.
Humans tend to categorise and order things as an energy saving mechanism. When you want to find a teaspoon you don’t have to open every drawer and cupboard in the kitchen to find it. You know which drawer you keep them in. Furthermore, once you open the drawer, you probably don’t have to keep picking out random items of cutlery until you find a teaspoon, as they’ll be organised into their own little compartment within the drawer. By spending some time and energy categorising and sorting the kitchenware, you save yourself time and energy each time you need to locate a specific object.
Humans also sort information, as well as physical objects. Think about any list of names: they will almost always be presented alphabetically to make individual easier to find. When you are going on holiday and want to choose a hotel, you might want to sort the options in lots of different ways, such as price, proximity to the beach, or the ratings of other customers.
As sorting is so important to us, it is no surprise that we have developed algorithms to assist us in sorting data, and there are plenty of them to choose from. Wikipedia alone list 34 different sorting algorithms.
But before we think about how we might develop a sorting algorithm, think about how you would go about instructing another person to sort a deck of playing cards. Imagine you have to write down instructions for sorting the deck. What would be your first instruction? Where would there be repetition of the same instruction? How would the person know that their deck is sorted?
Share your thoughts and ideas in the comments section below.