Simple Sorts

Sort a hand of cards the way you already do: selection sort and insertion sort, pass by pass, and why both slow down so fast as the list grows.

Updated

Simple Sorts

  1. Putting the Leaderboard in Order: Selection Sort (Apprentice): Put a time trial's leaderboard in order, fastest first, the way you'd do it by hand on a whiteboard, and count what that costs as the board grows: selection sort, and why it pays the same price even for a list that's already in order.
  2. One New Score on a Sorted Leaderboard: Insertion Sort (Apprentice): Keep a 10,000-player leaderboard in order as a new score arrives every few seconds, without sorting it all again: why re-sorting falls short, and the sort built on one slide, insertion sort, which is also fast on any list that's almost in order.

Exercise: Sort the Leaderboard

  1. Exercise: Sort the Leaderboard (Apprentice): A racing game's board of 10,000 players falls behind when every late score sorts it all again: slide each late score into place instead, write both of the chapter's sorts for a race's results, and let the tests check them, ties and a busy evening included.