jq 'sort_by(.age) | reverse | .[0]' data.json

Category: Data Science & Analysis

jq 'sort_by(.age) | reverse | .[0]' data.json

Find the object with the highest age

sort_by(.age) orders the array by age, reverse flips it to descending, and .[0] grabs the first element, the oldest record. This is the jq recipe for top-1 queries on any field. Use .[0:3] to take the top three instead. Sorting is stable, so ties keep their original order.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.