jmespath/jmespath.terminal

Please add option to sort keys

hawkeyej opened this issue · 2 comments

Since jpterm is a tool for humans, please add an option to sort the keys.

@hawkeyej could you provide an example of what you mean? jpterm supports the sort() function.

I think he means the equivalent of jq's -S:

Output the fields of each object with the keys in sorted order.

E.g. echo '[{"b":2, "a":3}]' | jp.py -S '[0]'
Would generate: { "a": 3, "b": 2 }

Alternatively, is there a way to do this with existing tools? E.g. [0].{sort(keys([0]))}

This would be useful for running unix diff on the output of two different jmespath invocations.