UPDATE
Would be wonderful if you checked my logic … but it’s working
{% assign space_groups = site.docs | group_by: 'space' %}
{% for s_group in space_groups %}
{{ s_group.name }}
{% assign CATEGORIES = "" | split: ',' %}
{% for s in s_group.items %}
{% assign CATEGORIES = CATEGORIES | push: s.category | uniq %}
{% endfor %}
{% for cat in CATEGORIES %}
{{ cat }}
{% assign local_list = s_group.items | where: "category", cat %}
{% for i in local_list %}
{{ i.title }} - {{ site.baseurl }}{{ i.url }}
{% endfor %}
{% endfor %}
{% endfor %}
Result:
Personal
Animals
Lexi the Spaniel - http://docs/Personal/Lexi-the-Spaniel/
A Cat Named Tivo - http://docs/Personal/a-cat-named-tivo/