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 db4c6c5..13446e7 100644 --- a/config.json +++ b/config.json @@ -206,17 +206,17 @@ "difficulty": 2 }, { - "slug": "allergies", - "name": "Allergies", - "uuid": "dac0e2f8-5ae9-4f06-b9a1-3afe1d44297a", + "slug": "all-your-base", + "name": "All Your Base", + "uuid": "a8eaf0dc-c5ff-46a2-9c47-86f738909db9", "practices": [], "prerequisites": [], "difficulty": 4 }, { - "slug": "all-your-base", - "name": "All Your Base", - "uuid": "a8eaf0dc-c5ff-46a2-9c47-86f738909db9", + "slug": "allergies", + "name": "Allergies", + "uuid": "dac0e2f8-5ae9-4f06-b9a1-3afe1d44297a", "practices": [], "prerequisites": [], "difficulty": 4 @@ -229,6 +229,14 @@ "prerequisites": [], "difficulty": 4 }, + { + "slug": "change", + "name": "Change", + "uuid": "12eb71ba-b6d0-4edf-af8f-8dbe195d1f27", + "practices": [], + "prerequisites": [], + "difficulty": 5 + }, { "slug": "eliuds-eggs", "name": "Eliud's Eggs", @@ -237,6 +245,14 @@ "prerequisites": [], "difficulty": 4 }, + { + "slug": "flower-field", + "name": "Flower Field", + "uuid": "1b636fca-bd18-4f54-b4d2-4f5cce1352a9", + "practices": [], + "prerequisites": [], + "difficulty": 5 + }, { "slug": "phone-number", "name": "Phone Number", @@ -262,36 +278,20 @@ "difficulty": 4 }, { - "slug": "word-count", - "name": "Word Count", - "uuid": "37104504-e817-4164-9379-c71b81ecd44c", - "practices": [], - "prerequisites": [], - "difficulty": 4 - }, - { - "slug": "change", - "name": "Change", - "uuid": "12eb71ba-b6d0-4edf-af8f-8dbe195d1f27", - "practices": [], - "prerequisites": [], - "difficulty": 5 - }, - { - "slug": "flower-field", - "name": "Flower Field", - "uuid": "1b636fca-bd18-4f54-b4d2-4f5cce1352a9", + "slug": "run-length-encoding", + "name": "Run-Length Encoding", + "uuid": "e2838aa6-284d-4dc2-9f9e-a81e3c275fb6", "practices": [], "prerequisites": [], "difficulty": 5 }, { - "slug": "run-length-encoding", - "name": "Run-Length Encoding", - "uuid": "e2838aa6-284d-4dc2-9f9e-a81e3c275fb6", + "slug": "word-count", + "name": "Word Count", + "uuid": "37104504-e817-4164-9379-c71b81ecd44c", "practices": [], "prerequisites": [], - "difficulty": 5 + "difficulty": 4 } ] }, diff --git a/problem-specifications b/problem-specifications index 99a6f01..96e23bd 160000 --- a/problem-specifications +++ b/problem-specifications @@ -1 +1 @@ -Subproject commit 99a6f01317bb993124cbe8bf8027a1cfdf2dc537 +Subproject commit 96e23bdf2ac750be56674752fa2ae6e42c7b7a33