y
y
yq
v4.x
Search…
⌃K
v4.x
y
y
yq
v4.x
Search…
⌃K
yq
How It Works
Upgrading from V3
Commands
Evaluate
Evaluate All
Shell Completion
Operators
Add
Alternative (Default value)
Anchor and Alias Operators
Array to Map
Assign (Update)
Boolean Operators
Collect into Array
Column
Comment Operators
Compare Operators
Contains
Create, Collect into Object
Date Time
Delete
Document Index
Encode / Decode
Entries
Env Variable Operators
Equals
Eval
File Operators
Flatten
Group By
Has
Keys
Length
Line
Load
Map
Multiply (Merge)
Parent
Path
Pick
Pipe
Recursive Descent (Glob)
Reduce
Reverse
Select
Slice Array
Sort
Sort Keys
Split into Documents
String Operators
Style
Subtract
Tag
Traverse (Read)
Union
Unique
Variable Operators
With
Usage
Output format
Working with CSV, TSV
Working with JSON
Working with Properties
Working with XML
Front Matter
Split into multiple files
GitHub Action
Tips, Tricks, Troubleshooting
Github Page
Powered By GitBook

Reverse

Reverses the order of the items in an array

Reverse

Given a sample.yml file of:
- 1
- 2
- 3
then
yq 'reverse' sample.yml
will output
- 3
- 2
- 1

Sort descending by string field

Use sort with reverse to sort in descending order.
Given a sample.yml file of:
- a: banana
- a: cat
- a: apple
then
yq 'sort_by(.a) | reverse' sample.yml
will output
- a: cat
- a: banana
- a: apple
Previous
Reduce
Next
Select
Last modified 3mo ago
Copy link
On this page
Reverse
Sort descending by string field