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
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
Unlock 19 remaining solutions by signing in and submitting your own entry
#20 Ben Hill / @KaizenSoze70 - Score: 91 - 12/19/17 @ 13:03
34GdGggPjjjjo<Esc>37GdG10GP37GdG19GP37GdGggP37G3<Esc>dGudG25GP37G3<Esc>dG16GP34GdGudG16GP37GdG22GPGddZZ
0 comments