📊 Sorting

5th Grade 💻 Coding

Sorting means putting items in a certain order: numbers from smallest to largest, names in alphabetical order, or players by score.

Free · US Letter · no sign-up
Google Classroom Save to Pinterest Email me

There are many sorting algorithms. One simple one: each time, find the smallest item and put it at the end of the sorted row. Another, like arranging playing cards in your hand: take one card at a time and slide it into the right spot among the cards you’ve already sorted. Both methods work, but with a huge number of items they’re slow.

Computer scientists have invented much smarter and faster ways to sort, and they’ve been comparing them for decades. In Python, you can just write sorted([5, 2, 9]) and get [2, 5, 9]. Sorting matters because it’s much easier to search through things that are sorted, for example with binary search.

For example

  • A league standings table is sorted by points, from the top team down.
  • The class roster is sorted alphabetically so it’s easy to find every student.

📌 Remember: Sorting = putting in order. Things in order are easy to find.

Quick quiz

  1. What is sorting?

  2. What does sorted([5, 2, 9]) return in Python?

  3. Why is sorting important?

🔎 Ask Thinkapedia another question