I want to sort this data structure by the object keys (easy with `-S` and sort the object values (the arrays) by the 'foo' property.

I can sort them with

```
jq -S '
  . as $in
  | keys[]
  | . as $k
  | $in[$k] | sort_by(.foo)
    ' < test.json

```

... but that loses the keys.

I've tried variations of adding  `| { "\($k)": . }`, but then I end up with a list of objects instead of one object. I also tried variations of adding to $in (same problem) or using `$in = $in * { ... }`, but that gives me syntax errors.

The one solution I did find was to just have the separate objects and then pipe it into `jq -s add`, but ... I really wanted it to work the other way. :-)

Test data below:

```
{
    "": [
        { "foo": "d" },
        { "foo": "g" },
        { "foo": "f" }
    ],
    "c": [
        { "foo": "abc" },
        { "foo": "def" }
    ],
    "e": [
        { "foo": "xyz" },
        { "foo": "def" }
    ],
    "ab": [
        { "foo": "def" },
        { "foo": "abc" }
    ]
}

```