diff --git a/.github/workflows/sorted.yml b/.github/workflows/sorted.yml new file mode 100644 index 0000000..0de38ff --- /dev/null +++ b/.github/workflows/sorted.yml @@ -0,0 +1,16 @@ +name: Exercise order + +on: + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + call-gha-workflow: + name: Check + uses: exercism/github-actions/.github/workflows/sorted.yml@main + with: + ordering: ".bucket, .lowercase_name" diff --git a/bin/sort-practice-exercises b/bin/sort-practice-exercises new file mode 100644 index 0000000..2ce7c22 --- /dev/null +++ b/bin/sort-practice-exercises @@ -0,0 +1,30 @@ +#!/bin/bash + +die () { echo "$*" >&2; exit 1; } + +(( $# == 2 )) || die "Usage: $0 " +[[ -r $2 ]] || die "$2 is not a readable file" + +tmp=$(mktemp) +jq -r ' + # Bucket by displayed difficulty. 0-3: easy; 4-7: medium; 8-10: hard. + def bucket(i): [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3][i]; + # Code injection to inject the sort literal expression. + def sort: sort_by('"$1"'); + .exercises.practice = ( + .exercises.practice | + # Add displayed difficulty + map(.lowercase_name = (.name | ascii_downcase)) | + map(.bucket = bucket(.difficulty)) | + # Leave hello-world at the top + if .[0].slug == "hello-world" then + [.[0]] + (.[1:] | sort) + else + sort + end | + map(del(.lowercase_name)) | + map(del(.bucket)) + ) +' "$2" > "$tmp" && \ +cat "$tmp" > "$2" +rm "$tmp" diff --git a/config.json b/config.json index 3da1e3c..2edadb5 100644 --- a/config.json +++ b/config.json @@ -142,6 +142,16 @@ "prerequisites": [], "difficulty": 2 }, + { + "slug": "eliuds-eggs", + "name": "Eliud's Eggs", + "uuid": "ebfaddfb-d094-4471-8771-fc09cf14274f", + "practices": [ + "numbers" + ], + "prerequisites": [], + "difficulty": 2 + }, { "slug": "etl", "name": "ETL", @@ -220,6 +230,14 @@ "prerequisites": [], "difficulty": 2 }, + { + "slug": "line-up", + "name": "Line Up", + "uuid": "c3691abc-0732-4487-bf91-bcbfd55f22ca", + "practices": [], + "prerequisites": [], + "difficulty": 2 + }, { "slug": "list-ops", "name": "List Ops", @@ -291,24 +309,6 @@ "prerequisites": [], "difficulty": 2 }, - { - "slug": "eliuds-eggs", - "name": "Eliud's Eggs", - "uuid": "ebfaddfb-d094-4471-8771-fc09cf14274f", - "practices": [ - "numbers" - ], - "prerequisites": [], - "difficulty": 2 - }, - { - "slug": "line-up", - "name": "Line Up", - "uuid": "c3691abc-0732-4487-bf91-bcbfd55f22ca", - "practices": [], - "prerequisites": [], - "difficulty": 2 - }, { "slug": "protein-translation", "name": "Protein Translation", @@ -468,17 +468,6 @@ "prerequisites": [], "difficulty": 2 }, - { - "slug": "triangle", - "name": "Triangle", - "uuid": "aab55f24-e31a-4e99-8c6c-12e69de7ce7c", - "practices": [ - "booleans", - "numbers" - ], - "prerequisites": [], - "difficulty": 2 - }, { "slug": "square-root", "name": "Square Root", @@ -500,13 +489,12 @@ "difficulty": 2 }, { - "slug": "word-count", - "name": "Word Count", - "uuid": "df93be4e-a862-4636-bb1c-e51e0e294797", + "slug": "triangle", + "name": "Triangle", + "uuid": "aab55f24-e31a-4e99-8c6c-12e69de7ce7c", "practices": [ - "strings", - "string-dicts", - "loops" + "booleans", + "numbers" ], "prerequisites": [], "difficulty": 2 @@ -521,6 +509,18 @@ "prerequisites": [], "difficulty": 2 }, + { + "slug": "word-count", + "name": "Word Count", + "uuid": "df93be4e-a862-4636-bb1c-e51e0e294797", + "practices": [ + "strings", + "string-dicts", + "loops" + ], + "prerequisites": [], + "difficulty": 2 + }, { "slug": "circular-buffer", "name": "Circular Buffer",