Skip to content

Sorting Introduction

Binary search was a few hundred times faster than linear search — but it demanded a sorted list, and nobody said where sorted lists come from. They come from sorting algorithms, and you already run one every time you pick up a hand of cards. Today you'll figure out what it is you've been doing all along, and write it down.

A hand of playing cards being sorted.


Overview

Imagine you are holding a hand of playing cards that are not in order. You want to organize them from lowest to highest value (for example: 2 → 10 → Jack → Queen → King → Ace). You'll write a step-by-step algorithm in plain language that explains how you would sort the cards while holding them in your hand.

Builds on: Search Algorithms — binary search needed a sorted list; this is where sorted lists come from.

You've got it when…

  • Your algorithm is written in clear, complete sentences with numbered steps.
  • It covers every card in the hand, from the first to the last.
  • Another student could follow it exactly — with real cards — without asking you anything.
  • It stays within the constraints below.

Collaboration & AI

Work: On your own. If you have a deck handy, testing your algorithm on a neighbor is fair play — watching them follow your words literally is the fastest way to find the gaps.

AI — AIAS Level 1, No AI: The algorithm in your head is the one we're after. Write it down yourself. What the levels mean.


Your Task

Write a step-by-step algorithm in plain language that explains how you would sort the cards while holding them in your hand.

Requirements

Your algorithm must:

  • Be written in clear, complete sentences
  • Use numbered steps
  • Be detailed enough that another student could follow it exactly
  • Describe how you:
    • Look at cards one at a time
    • Decide where a card belongs
    • Move cards to make space
    • Keep your cards organized as you go

Constraints

  • You may only use the cards in your hand (no table or extra piles)
  • You must keep the cards in your hand at all times
  • You may only move one card at a time
  • You may use standard playing cards, or just imagine a stack of cards with random numbers or letters if that is simpler.

Consider

  • How do you handle the first card?
  • What do you do when you pick up a new card?
  • How do you find the correct position for that card?
  • What happens to the cards that are already in your hand?

Turn It In

  • Your card-sorting algorithm, in your notebook.

How It's Graded

This lab is worth up to 4 points. One score covers everything you turn in.

Score What it looks like
4 — Excellent Numbered, complete sentences that cover every card from first to last, stay within the constraints (cards in hand, one card moved at a time), and are precise enough that another student with real cards could execute them without asking — including exactly where each new card goes and how the others make room.
3 — Above Average A complete algorithm within the constraints, with one ambiguous step a literal-minded card holder would trip on.
2 — Average The idea is described but not the steps — "put each card where it belongs" is a wish, not an algorithm.
1 — Below Average Fragmentary steps that don't get a hand of cards sorted.
0 — Failing Nothing in the notebook.