I have the following array:
[{
"name": "Object 1",
"prop1": 5,
"prop2": 2
}, {
"name": "Object 2",
"prop1": 6,
"prop2": 4
}, {
"name": "Object 3",
"prop1": 5,
"prop2": 3
}]
I want to sort this array analogous to this SQL ORDER BY prop1 DESC, prop2 ASC
so I have this result:
[{
"name": "Object 2",
"prop1": 6,
"prop2": 4
}, {
"name": "Object 1",
"prop1": 5,
"prop2": 2
}, {
"name": "Object 3",
"prop1": 5,
"prop2": 3
}]
How can I sort an array a) descending by a key and b) by multiple keys?
Version: jq 1.5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With