diff --git a/pkg/yqlib/doc/headers/sort-keys.md b/pkg/yqlib/doc/headers/sort-keys.md index 932b855b..36327815 100644 --- a/pkg/yqlib/doc/headers/sort-keys.md +++ b/pkg/yqlib/doc/headers/sort-keys.md @@ -5,7 +5,7 @@ The Sort Keys operator sorts maps by their keys (based on their string value). T Sort is particularly useful for diffing two different yaml documents: ```bash -yq eval -i 'sortKeys(..)' file1.yml -yq eval -i 'sortKeys(..)' file2.yml +yq eval -i -P 'sort_keys(..)' file1.yml +yq eval -i -P 'sort_keys(..)' file2.yml diff file1.yml file2.yml ``` diff --git a/pkg/yqlib/doc/sort-keys.md b/pkg/yqlib/doc/sort-keys.md index e8f4d6dc..c0a283df 100644 --- a/pkg/yqlib/doc/sort-keys.md +++ b/pkg/yqlib/doc/sort-keys.md @@ -5,8 +5,8 @@ The Sort Keys operator sorts maps by their keys (based on their string value). T Sort is particularly useful for diffing two different yaml documents: ```bash -yq eval -i 'sortKeys(..)' file1.yml -yq eval -i 'sortKeys(..)' file2.yml +yq eval -i -P 'sort_keys(..)' file1.yml +yq eval -i -P 'sort_keys(..)' file2.yml diff file1.yml file2.yml ``` @@ -19,7 +19,7 @@ b: bing ``` then ```bash -yq eval 'sortKeys(.)' sample.yml +yq eval 'sort_keys(.)' sample.yml ``` will output ```yaml @@ -49,7 +49,7 @@ aParent: ``` then ```bash -yq eval 'sortKeys(..)' sample.yml +yq eval 'sort_keys(..)' sample.yml ``` will output ```yaml diff --git a/pkg/yqlib/operator_sort_keys_test.go b/pkg/yqlib/operator_sort_keys_test.go index 130b8019..462771e6 100644 --- a/pkg/yqlib/operator_sort_keys_test.go +++ b/pkg/yqlib/operator_sort_keys_test.go @@ -8,7 +8,7 @@ var sortKeysOperatorScenarios = []expressionScenario{ { description: "Sort keys of map", document: `{c: frog, a: blah, b: bing}`, - expression: `sortKeys(.)`, + expression: `sort_keys(.)`, expected: []string{ "D0, P[], (doc)::{a: blah, b: bing, c: frog}\n", }, @@ -16,7 +16,7 @@ var sortKeysOperatorScenarios = []expressionScenario{ { skipDoc: true, document: `{c: frog}`, - expression: `sortKeys(.d)`, + expression: `sort_keys(.d)`, expected: []string{ "D0, P[], (doc)::{c: frog}\n", }, @@ -25,7 +25,7 @@ var sortKeysOperatorScenarios = []expressionScenario{ description: "Sort keys recursively", subdescription: "Note the array elements are left unsorted, but maps inside arrays are sorted", document: `{bParent: {c: dog, array: [3,1,2]}, aParent: {z: donkey, x: [{c: yum, b: delish}, {b: ew, a: apple}]}}`, - expression: `sortKeys(..)`, + expression: `sort_keys(..)`, expected: []string{ "D0, P[], (!!map)::{aParent: {x: [{b: delish, c: yum}, {a: apple, b: ew}], z: donkey}, bParent: {array: [3, 1, 2], c: dog}}\n", },