How would you calculate the median (P50) of an array using jq? The jq manual describes how to calculate the mean, but I'd like to get the median.
Algorithm: Given a list of numbers, sort it. If there are an odd number of entries then pick the middle one. If there are an even number of entries then calculate the mean of the middle two.
Examples:
echo '[1,5,9,3]' | jq <ANSWER> # should output 4, since it's the mean of 3 and 5
echo '[1,9,2]' | jq <ANSWER> # should output 2, since it's the middle element
echo '[]' | jq <ANSWER> # undefined