Learn C++ STL

Lesson 4 of 9 · sort, Comparators and Lambdas: Tell the Algorithm What You Mean

Module 12 · sort, Comparators and Lambdas: Tell the Algorithm What You Mean

When to Sort, and When a set, a priority_queue or Counting Does It Better

Free with an accountReading

Kenji sorts everything. He sorts a million marks to print them in order, and he sorts a million scores to find the best ten. When a new score arrives, he sorts all of them again. Every program works. Amara asks him one question: what did the job need? This lesson is her answer, with a chart, a flowchart and one lab of nine timed jobs.

Checking what this lesson needs for you…

What is inside When to Sort, and When a set, a priority_queue or Counting Does It Better

  1. Five questions before you sort
  2. The comparison chart
  3. A million values, measured
  4. The decision flowchart
  5. When not to sort
  6. The honest default