top of page

# Can you think like a programmer? Sort these numbers in ascending order…

Let’s start by sorting these numbers in ascending order. Go ahead, do it. Write down the ordered list.

>>> 4, 8, 2, 10, 3, 6

Done? This should have been a straightforward task that might have taken you a couple of seconds to do.

The human brain can do this task with very little thinking. But what is it that you are actually doing? How are you deciding which number to pick first, etc?

So here’s the harder exercise: can you deconstruct the process of sorting these numbers into individual, clear steps? Try to think of every single step, without taking anything for granted. Give it a go before reading on.

>>>

Computer programming is about learning how to deconstruct how the human brain solves problems. The brain does a lot of stuff on autopilot, which means we take them for granted. But when we’re telling a computer what to do, we cannot afford to skip any steps because they’re obvious for us - we need to instruct the computer to do every single step necessary to solve a problem, in the right order. Master this skill, and prog

ramming becomes easy.

So, back to our numbers. Have you listed all the required steps? Are you sure you haven’t missed anything out? Here’s my take on this:

1. Look at the first number

2. Compare this number with the second number and retain the lower of the two numbers in your mind.

3. Compare this number with the third number in the list, and again retain the lower of the numbers.

4. Repeat this process until you reach the end of the list.

5. The number you’re left with is the lowest number in the list, remove it from the list and start a new list (the ordered list) with this number.

6. Repeat steps 1 to 5 with the remaining numbers in the list, and keep repeating these steps until you exhaust all the numbers in the list.

And this is your computer program. We then need to code this into whatever programming language we choose to use, but the hard work is done.

61 views

### Python Coding for Young People

Codetoday Unlimited is for the curious teenager or preteen keen to learn proper Python coding. Stephen's courses start from the basics and carry on to intermediate and advanced levels.