Closed itchyny closed 2 years ago
The sort_by filter of jq allows to specify multiple comparators in case the first one emits the same value.
sort_by
$ jq -nc '[{x:1,y:2},{x:2,y:2},{x:2,y:1},{x:1,y:1}] | sort_by(.x,.y)' [{"x":1,"y":1},{"x":1,"y":2},{"x":2,"y":1},{"x":2,"y":2}] $ xq -nc '[{x:1,y:2},{x:2,y:2},{x:2,y:1},{x:1,y:1}] | sort_by(.x,.y)' [1,2,1,2]
The
sort_by
filter of jq allows to specify multiple comparators in case the first one emits the same value.