Added custom sort map example

This commit is contained in:
Mike Farah
2022-10-17 15:03:47 +11:00
parent d16ee386d2
commit 6db7acbf69
4 changed files with 35 additions and 0 deletions
@@ -11,3 +11,6 @@ diff file1.yml file2.yml
```
Note that `yq` does not yet consider anchors when sorting by keys - this may result in invalid yaml documents if your are using merge anchors.
For more advanced sorting, using `to_entries` to convert the map to an array, then sort/process the array as you like (e.g. using `sort_by`) and convert back to a map using `from_entries`.
See [here](https://mikefarah.gitbook.io/yq/operators/entries#custom-sort-map-keys) for an example.