How to filter or sort with template

I would like to display a sensor that tells me based on 5 other sensors (pollution sensors) which one is causing the most pollution.

for example i have a co2, tvoc, pm2.5, pm10 sensor and i calculate for every sensor a given value that combined gives me a AQI.
Now what i would like to have is a sensor that can tell me based on the various sensors which of those is the most contributing to the AQI.

this is my code that i use for calculating the AQI.

The part that is excluded is where you would count up all calculated values ending with “p_unit”.

{% set pm10 = states('sensor.24hr_average_pm10_woonkamer')|float %}
{% set pm2_5 = states('sensor.24hr_average_pm2_5_woonkamer')|float %}
{% set co2 = states('sensor.average_co2_woonkamer')|float %}
{% set no = states('sensor.24hr_average_nitrogen_dioxide_woonkamer')|float %}
{% set tvoc = states('sensor.24hr_average_tvoc_woonkamer')|float %}
{% set aqi_max_rng = 100 %}
{% set pm10_max = 125 %}
{% set pm2_5_max = 150 %}
{% set co2_max = 5000 %}
{% set no_max = 80 %}
{% set tvoc_max = 150 %}
{% set pm10_p_unit = (aqi_max_rng / pm10_max)*pm10 %}
{% set pm2_5_p_unit = (aqi_max_rng / pm2_5_max*pm2_5) %}
{% set co2_p_unit = (aqi_max_rng / co2_max)*co2 %}
{% set no_p_unit = (aqi_max_rng / no_max)*no %}
{% set tvoc_p_unit = (aqi_max_rng / tvoc_max)*tvoc %}
{{pm10_p_unit|round(0)}}
{{pm2_5_p_unit|round(0)}}
{{co2_p_unit|round(0)}}
{{no_p_unit|round(0)}}
{{tvoc_p_unit|round(0)}}