home / skills / bdambrosio / cognitive_workbench / test-json-sql-sort
This skill tests and explains SQL sort by implementing descending order on a papers collection and validating output.
npx playbooks add skill bdambrosio/cognitive_workbench --skill test-json-sql-sortReview the files below or copy the command above to add this skill to your agents.
---
name: test-json-sql-sort
description: Tests sort primitive (ORDER BY)
manual_only: true
---
# Test Sort Primitive
**Self-contained:** Creates test data internally
**Input:** Creates $papers collection (years: 2020, 2021, 2023, 2022)
**Operation:** Sort by year descending
**Expected Output:** $sorted collection ordered: 2023, 2022, 2021, 2020
This skill validates the sort primitive (ORDER BY) by running a focused test that creates its own data and asserts correct descending ordering. It is self-contained and requires no external fixtures. The test confirms that a collection of papers is ordered by year from newest to oldest.
The skill generates an internal $papers collection with four entries dated 2020, 2021, 2023, and 2022. It applies the sort operation to order the collection by the year field in descending order. The test compares the resulting $sorted collection to the expected sequence 2023, 2022, 2021, 2020 and fails if any position differs.
Does the test rely on external databases or fixtures?
No. The test is self-contained and creates the $papers collection internally.
What exact order is expected?
The expected $sorted order is years: 2023, 2022, 2021, 2020.