Sort nested JSON result

I’m trying to sort a JSON response. In this example, I can sort ‘summary’, but I can’t seem to sort ‘date’

{% set value = [

{
    "summary": "Pete's birthday",
    "description": null,
    "location": null,
    "start": {
        "date": "2022-10-11"
    },
    "end": {
        "date": "2022-10-12"
    }
},
{
    "summary": "Anniversary!!",
    "description": null,
    "location": null,
    "start": {
        "date": "2022-10-16"
    },
    "end": {
        "date": "2022-10-17"
    }
}

] %}

{{ value | sort(attribute=“summary”) }}

Does anyone have pointers? It doesn’t make sense to sort on summary in this context :slight_smile:
I tried to {{ value | sort(attribute=["start"][date]) }} and some variations of that but to no avail. I always get: **UndefinedError: 'dict object' has no attribute 'date'**

Thank you!

use

{{ value | sort(attribute="start.date") }}
1 Like