What is sorting, and why do we do it?
Humans like to categorise and order things, to greater or lesser degrees.
Think about the books on a bookshelf. Maybe the books are displayed randomly, but often they’ll be organised. This could be by size, by author, by subject matter, or alphabetically by title.
Remember 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 goods 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 names 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, it is no surprise that there are a number of different 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 you think about how you 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?