title: How can you sort a JSON object efficiently using JQ
body: <p>I've got JSON in the format</p>
  
  <pre><code>{
    "a": {
      "size":3
    },
    "b": {
      "size":2
    },
    "c": {
      "size":1
    }
  }
  </code></pre>
  
  <p>I need to sort it by size, e.g.:</p>
  
  <pre><code>{
    "c": {
      "size": 1
    },
    "b": {
      "size": 2
    },
    "a": {
      "size": 3
    }
  }
  </code></pre>
  
  <p>I have found a way to do it, e.g.:</p>
  
  <pre><code>. as $in | keys_unsorted | map ({"key": ., "size" : $in[.].size}) | sort_by(.size) | map(.key | {(.) : $in[.]}) | add
  </code></pre>
  
  <p>but this seems quite complex so I'm hoping there's a simpler way that I've overlooked?</p>