#2884·yq

sort and sort_by silently accept types with undefined ordering

Author: dhx-mike-palandraCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbugv4

Compare the following two commands (bash + yq):

$ yq -n '[{"a":1},{"a":0}] | max'
Error: maps not yet supported for comparison

$ yq -n '[{"a":1},{"a":0}] | sort'
- a: 1
- a: 0

If the error message for max is true, then sort should fail for the same reason. Not only is sort silent in such cases, but also the value it does return might be considered incorrect (e.g. compared to jq).

Same problem for arrays:

$ yq -n '[{"a":1},{"a":0}] | map([.a]) | max'
Error: arrays not yet supported for comparison

$ yq -n '[{"a":1},{"a":0}] | map([.a]) | sort'
- - 1
- - 0

Similar issues with sort_by(exp); i.e. when exp evaluates to an array or object.

Version of yq: v4.53.6 Operating system: linux Installed via: binary release