Set a tie breaker for sorted results
Use the opposite Shift key for paired punctuation. · 184 words
Start with the source records, an exact output shape, and a rule for every possible tie. For example, a museum gift shop provides: A, Blue Mug, score 92, date 2025-01-14; B, Red Mug, score 92, date 2025-01-09; C, Green Mug, score 88, date 2025-02-02. The prompt says: "Sort by score from highest to lowest. If scores tie, use date from oldest to newest. If dates also tie, use code from A to Z. Return a JSON array with exactly code, name, score, and date. Return no other text."
The result is easy to check. B comes before A because B has the earlier date; C follows because its score is lower. Put the rule before the data, then repeat the expected result after the data: the first defines behavior, and the example confirms application. A program can check that the output is an array, every item has the four required fields, score is a number, and the order matches the keys. If a score or date is missing, ask for null rather than guessing. For this case, the checkable order is [B, A, C].
Check your recall
What is the full tie-breaking chain after score, and what exact item order should the source produce?
Check your answer
Sort score from highest to lowest. For equal scores, sort date from oldest to newest. For equal dates, sort code from A to Z. The expected order is B, A, C.
Sources and credits
Original KeyTouch lesson. Background reading · JSON Schema · Understanding JSON Schema.