But there’s no reason to use both. You have a list of dictionaries that has both built into it.
{% set prices = state_attr('sensor.nordpool_kwh_nl_eur_4_10_021','today') %}
{% set ns = namespace(items=[]) %}
{% for price in prices %}
{% set ns.items = ns.items + [{'hour': loop.index0, 'price': price}] %}
{% endfor %}
{{ ns.items | sort(attribute='price') }}
If you’re struggling using that, just ask questions.