## Sorting and comparing can’t be that hard?!

I’ve always loved categorizing, sorting and grouping things. This behavior is instinctive in humans: edible plants, dangerous plants, people we know and trust, people we see often, and people we don’t know anything about. Since humans perform this task all the time, we also need to do this digitally. We use the concepts equality, comparison, sorting and sequence. First off, to figure out if two items can be grouped together, we need to determine if they are equal or not. Sounds simple, right? While this sometimes is simple, it can also be a maddeningly complex task. Telling a computer how to sort or compare for us requires us to be very exact in our instructions. The computer is dumb as a bag of hammers and must be given instructions in extreme detail. That means that we need to really know how to compare and measure equality, and the following exercises are designed to explore these concepts. Each activity is by design simple, but it’s easy to make them sufficiently complex that grownups will have fun too. Don’t be afraid to join in, you’re likely to get some suprises along the way yourself!

## When are two things equal?

My 3 year old son loves houses. While we’re driving, suddenly there will be an enthusiastic comment from the backseat: “Look, grandma and grandpa’s house!” But their house is in a different place altogether and doesn’t look anything like any house I’m seeing. After many drives in which my son insists upon seeing my parent’s house, I finally figured out that the key was the color. That is not at all how I compare houses! For a house to be the same it has to be in the same location, be built from the same materials and contain the same stuff and the same people. But who’s to say my interpretation of equality is more correct than my son’s? What if the house is built from the same specifications, does that make them equal? And how on earth is this relevant to teaching kids about our digital world?

When we compare things in computers, we have to tell the computer exactly what it means that two items are equal. To do that, we must know which characteristics are important. There are many ways to explore this.

**Suggested activities:**

- Find a bunch of toys that can be compared, such as cars in red, black, maybe along with animals (or any other item) in the same colors. Let the children sort the set of items on their own. Kids will sort this set differently, maybe by color or by animal/vehicle. Some may have few categories (cars, animals), while others have many (bus, truck, small car etc). If several children do the same activity with the same set of items, this is a good opportunity to talk about how different people experience the world.
- Remove some of the items from the set and have the kid sort again. How does this compare? Some kids will sort differently, others will not. Talk about any differences, or why there were no differences from before.
- For the more experienced or older kids: how many different ways can you sort the same set of items? Go mad and see how many ways you can find. Some tips to get started: divide by weight, whether the first letter of the word is a vowel or not, whether the item is metallic or not, there are endless opportunities. Remember that the only thing we’re interested in is whether or not a particular item falls in one of two categories, equal or not equal to some standard. Make a competition about finding the weirdest equality rule!
- Prepare a small set of items and a set of rules for what should be equal. Let the child sort the set by the given rules. Change the rules and categorize again.
- Let the child come up with rules on how to categorize/sort the set. This particular activity can be quite challenging and is subtly different from just sorting differently. Here you also have to vocalize the exact rules.
- Let the child come up with sets of items that someone else can categorize. Besides toys, what could be used? How about tools or kitchen utensils?

*Different datasets and my oldest kid's categories for the kitchen items. What other categories can you find?*

What does it that one characteristic is more important than another one? If we categorize by size, it also means that we don’t care about the other characteristics the item has (in this particular instance, that is). Spend time discussing what it means to prioritize or rank characteristics and that different characteristics matter in different situations.

Exploring how people view the world and think about equality can be very hard for children as their view of the world is challenged on even simple problems. Many adults also find this surprisingly difficult. Spend time talking about how the participants think about equality, what is the same and what is different between different people. Sometimes it isn’t obvious even though it seems so clear when you think about it! Once kids have gone through these activities a few times, they’ll become better at seeing different ways to solve equality problems. These skills are very useful, both when programming, but also in general. Exploring different aspects of a problem makes it easier to see different solutions and gives a much better understanding of the problem!

### Some practical tips

- Start with a simple set and expand in later iterations. Choose the items so that there aren’t too many obvious categories to choose between. The first game can have only two obvious categories just to ease kids into the game.
- If the kids want to sort or categorize in a different way, let them do that as a start. Try to discuss how they could change their sets afterwards, or ask if you can sort it differently and show them how you would sort it. This is a nice way to open a discussion without saying one is more correct than the other.
- Introduce more strict rules as the child becomes more familiar with the game.
- Avoid saying what they’re doing is wrong. Ask open questions about how people reason differently. If they use 4 categories instead of 2, you could ask “But what if there was only room for two categories?” or “how would you solve this if there were only two boxes to store the items in?”
- Demonstrate the game by sorting or categorizing yourself if they don’t start on their own
- Leave the items out for a while after the child leaves the game. You might even sort them and leave that for the child to discover. This might prompt them to go back to the game should the lose interest.
- The more creative variants of the game requires a fresh mind and maturity. If they become frustrated, try introducing more rules and thus limiting how creative they have to be in order to play the game.

### More activity suggestions, maybe for the older kids:

- Present two items. These are in some way "equal", and you decide before handing them out what the rules are. Let the participant figure out which rules have been used to decide equality. Decide how many rules are used, and let the participant know (or not, if you want a real challenge). Start easy and make it more complicated as the players become more familiar with the activity. Some examples characteristics: number of edges, color, number of wheels, vehicle vs animals, same first letter of the name (maybe even in a different language), number of letters of the item name, items that have names that are homonyms or homophones (night and knight, write and right)
- Do the same exercise as above, but present two items that are not equal.
- Let the kid figure out rules of equality present two items. Let another child (or a grownup) figure out what the rules are.

*1, 2, 3. Before. Working on it. After. Kitchenware vs. vehicles*

## When is something bigger than something else?

From categorizing, the next natural step is to sort and arrange items in sequences. At some point, all kids go through some variant of “our car is bigger than your car”. But what makes one car larger than the other? Is it the volume of the car? The height? The length? Top speed? Acceleration? Motor power? Any of these characteristics, or maybe a combination of them, can be used to sort cars from smallest to largest. Just as categorizing, there are many ways to sort items.

### Suggested activities:

- Sort colors: how can this be done? By the first letter? By frequency? By the rainbow? Can you even say that one color is larger than another?
- Sort animals (or any other set of objects).
- Can you come up with items that can’t be sorted?
- If you have several kids playing, sort the kids! How many ways can they be sorted (height, first name, last name, colors of clothing, where they sit in relation to the door in class, order in which they came through the door etc)
- Let the kids come up with the sorting rules. It could be a good idea to let one the the computer and give the rules, and cycle who the computer is. Getting all the kids to agree on sorting is in many cases futile.
- Present a sorting criteria and a set of items, and let the kid sort. The kid doing the sorting becomes the processor (CPU). A variant here is to let the kid figure out what the sorting rules are and have other children figure out what the rules are.

## What basic principles have we explored?

In this post we’ve looked at equality, comparison (the act of comparing items by a given set of rules) and sorting, but also context and assumptions. An assumption is something we accept as true without proof. By exploring how different people compare and sort we also explore what assumptions they make and what their context (or situation) is. Discuss what this means in our everyday lives. Can you think of assumptions you make every day as you prepare food or do chores? My favorite example is making pancake batter: how would a computer interpret the following instructions: “Take two eggs, mix with flour, salt, suger and milk”? How is this mixed? What type of flour is used? Can you think of other assumptions you make in this particular situation?

Why is this even important in programming? When we make systems, other people use them. We need to be able to put ourselves in their shoes and picture how they could interpret the systems. We also need to tell not only the computer, but also the users, which assumptions we make.

Our assumptions are usually dependant on context, or the circumstances surrounding a particular situation. Can you think of different situations (contexts) where the assumptions you make will differ? One example is which side of the road you should keep to. If you’re a pedestrian, you keep to the left side (in Norway), whilst if you’re driving you’ll keep to the right. Are there contexts in which these assumptions are untrue? What other examples can you find, either in real life or in apps/web pages you normally use?

We make assumptions all the time, and they vary naturally with the context we’re in. This is mostly fine in the real world, but when you present people with web pages or apps you have to be real careful in giving the necessary context and assumptions so that the users know how to use your system correctly. Exploring assumptions and context is both challenging and fun, and sorting and categorizing is an easy way into this way of thinking. Hope you had fun and learned something new along the way!