>_ IzzyLab

Topic breakdown

The task consists of two stages joined by a pipeline. First datamash groups rows by the key column (the -g flag) and sums the values within each group; grouping needs input sorted by key — that's what the -s flag is for. Then the resulting rows need to be ordered by the sum column, and that's already a job for sort, which has numeric comparison (-n), reverse order (-r), and key-column selection (-k). Putting both steps into a single pipeline gives you the products from best-seller to least.

What's checked

  1. the product with the max sum comes first
  2. all products with correct sums

What it looks like