Sort yaml structures alphabetically by root key names
sometimes we want to sort structures alphabetically in yaml files
Start file
c: required: false h: optional: true choice: - true - false f: required: true e: optional: true choice: - b - a g: optional: false j: required: true a: required: true i: required: false d: required: false b: optional: true choice: - 1 - 2
End file
a: required: true b: optional: true choice: - 1 - 2 c: required: false d: required: false e: optional: true choice: - b - a f: required: true g: optional: false h: optional: true choice: - true - false i: required: false j: required: true
View Diff
[1mdiff --git a/old.yml b/new.yml[m [1mindex a925691..a36642f 100644[m [1m--- a/old.yml[m [1m+++ b/new.yml[m [36m@@ -1,14 +1,17 @@[m [32m+[m[32ma:[m [32m+[m[32m required: true[m [32m+[m [32m+[m[32mb:[m [32m+[m[32m optional: true[m [32m+[m[32m choice:[m [32m+[m[32m - 1[m [32m+[m[32m - 2[m [32m+[m c:[m required: false[m [m [31m-h:[m [31m- optional: true[m [31m- choice:[m [31m- - true[m [31m- - false[m [31m-[m [31m-f:[m [31m- required: true[m [32m+[m[32md:[m [32m+[m[32m required: false[m [m e:[m optional: true[m [36m@@ -16,23 +19,20 @@[m [me:[m - b[m - a[m [m [32m+[m[32mf:[m [32m+[m[32m required: true[m [32m+[m g:[m optional: false[m [m [31m-j:[m [31m- required: true[m [31m-[m [31m-a:[m [31m- required: true[m [32m+[m[32mh:[m [32m+[m[32m optional: true[m [32m+[m[32m choice:[m [32m+[m[32m - true[m [32m+[m[32m - false[m [m i:[m required: false[m [m [31m-d:[m [31m- required: false[m [31m-[m [31m-b:[m [31m- optional: true[m [31m- choice:[m [31m- - 1[m [31m- - 2[m [32m+[m[32mj:[m [32m+[m[32m required: true[m
Solutions by @tpenguinltg:
Unlock 2 remaining solutions by signing in and submitting your own entry