У меня есть куча JSON объектов как:
{"AccountID":"290859614811","number_of_requests":"59944"}
{"AccountID":"421258792169","number_of_requests":"3132"}
{"AccountID":"433594311540","number_of_requests":"1541"}
{"AccountID":"406912498377","number_of_requests":"678"}
{"AccountID":"850981987534","number_of_requests":"558"}
{"AccountID":"763725063017","number_of_requests":"470"}
{"AccountID":"notaccount","number_of_requests":"8"}
....
Я пытаюсь отсортировать их в порядке возрастания на основе number_of_requests.
, но когда я запускаю следующее:
jq -S '.results[] | map( { (.field) : .value} ) | add ' FILENAME | jq -s -c 'sort_by(.number_of_requests)[]'
Я получаю:
{"AccountID":"433594311540","number_of_requests":"1541"}
{"AccountID":"421258792169","number_of_requests":"3132"}
{"AccountID":"763725063017","number_of_requests":"470"}
{"AccountID":"850981987534","number_of_requests":"558"}
{"AccountID":"290859614811","number_of_requests":"59944"}
{"AccountID":"406912498377","number_of_requests":"678"}
{"AccountID":"notaccount","number_of_requests":"8"}
...
По сути, функция sort_by обрабатывает "558" / "59944" как меньшее, чем "8", " 6 "et c. Есть ли способ обойти это?