Sequencing

Every morning you do the same little dance without even thinking about it: get out of bed, brush your teeth, eat breakfast, put on your coat, head out the door. Notice something? You do those things in an order — one after another, first to last. You wouldn't put your coat on before getting out of bed!

A list of steps done in order, one after another, is called a sequence. When you already know the steps (from ), sequencing is simply putting them in the right order and doing them from top to bottom, one at a time.

Top to bottom, one at a time

Think of a recipe for a jam sandwich. You read it like a list, starting at the top and working your way down. You don't skip about — you finish step 1 before you start step 2.

Press play and watch each step light up in turn. That's exactly how a sequence works: step 1, then step 2, then step 3, all the way to the end. Nothing jumps the queue.

A program runs its lines in order too

A computer program is a sequence as well! The computer reads your lines from the top and runs them one after another, right down to the bottom — just like reading a recipe. Here are three lines that each print a word. Press Run and see what pops out.

console.log("Ready"); console.log("Steady"); console.log("Go!");

The words come out in the same order as the lines: Ready, then Steady, then Go!. The computer never reads the last line first. Now try swapping the lines around in your head — the words would come out in a different order, wouldn't they? That's the big idea of this page.

The order changes the outcome

Here's the part that catches everyone out: with the very same steps, a different order can give a completely different result. Take getting ready to go outside:

Same two steps. Swap the order and the whole thing falls apart. That's why sequencing matters so much: getting the steps right isn't enough — you have to get them in the right order.

Not quite — sometimes swapping two steps is fine! Pouring the milk before the cereal or the cereal before the milk both leave you with a nice bowl of breakfast. But loads of the time the order is everything: you must butter the bread before you fold the sandwich shut, and you must wake up before you can do anything at all. A clever step-planner learns to spot which steps can swap and which absolutely cannot.

Beware of steps that only make sense in one order! "Put on your socks, then your shoes" works a treat. "Put on your shoes, then your socks" is a muddle — same steps, ruined result. And some orders are just plain impossible: "get dressed, then get out of bed" can't work, because you can't get dressed while you're still tucked up asleep. A computer won't warn you — it runs your lines from top to bottom exactly as written, muddle and all.