Is it possible to determine the order of evaluation?

I have some templates that depend on one another and need to be evaluated in a given order. Currently I solve this using staggered triggers:

- trigger:
    - platform: time_pattern
      minutes: "59"
  sensor:
    - name: Solar Zaehler
      unique_id: t_solar_zaehler
      device_class: energy
      unit_of_measurement: "kWh"
      state: "{{ states('sensor.shellypmminig3_84fce638860c_energy')|float(0) }}"
      attributes:
        m00: "{{ states('sensor.shellypmminig3_84fce638860c_energy')|float(0) }}"
        m60: "{{ this.attributes['m00'] }}"
- trigger:
    - platform: time_pattern
      minutes: "59"
      seconds: "5"
  sensor:
    - name: Solar Ertrag
      unique_id: t_solar_ertrag
      device_class: energy
      unit_of_measurement: "kWh"
      state: "{{ (state_attr('sensor.t_solar_zaehler', 'm00') - state_attr('sensor.t_solar_zaehler', 'm60'))|float(0) }}"
- trigger:
    - platform: time_pattern
      minutes: "59"
      seconds: "10"
  sensor:
    - name: Solar Wert
      unique_id: t_solar_wert
      state: "{{ (states('sensor.t_solar_preis')|float(0) * states('sensor.t_solar_ertrag')|float(0))|float(0) }}"
      unit_of_measurement: "Eur"

This is not very elegant. The two attributes in the first example above work, which means they are evaluated in the reverse order from how they are witten down. A second related problem is this template sensor created in the UI:

{{ (states('sensor.gesamtwert_2')|float(0) / states('sensor.gesamtertrag_2')|float(1))|float(0) }}

It listens to both sensors (from utility meter) which of course creates a short spike at every update. I could set an explicit trigger, but I would have to know which of the two is evaluated last. If there is no other solution I can stick with my time triggers a few seconds apart.

If they need to be evaluated in a given order, then make a script that does that and the script also sets the values of your sensors.

I don’t understand. Can you give a simple example? I can script actions but not sensors. When a template sensor is defined it gets evaluated (unless I set a trigger or condition to never). Do you mean a script with a sequence of “update entity” actions? I have this in an automation:

action:
  - target:
      entity_id:
        - sensor.leistung_phase_1
        - sensor.leistung_phase_2
        - sensor.leistung_phase_3
        - sensor.gesamtleistung_export
        - sensor.gesamtleistung_import
    data: {}
    action: homeassistant.update_entity

(It speeds up sensor readings from once every two minutes to once every five seconds to help me monitor changes on switching stuff on and off.) If I split that up into a sequence of separate actions, perhaps even with a slight delay in between, then I could determine a sequence. Is that really better than my current solution of staggered time triggers?

Just use one trigger, define the values as variables in order from top to bottom and apply them as needed

- trigger:
    - platform: time_pattern
      minutes: "59"
  action:
    - variables:
        m60: "{{ state_attr('sensor.t_solar_zaehler', 'm00') | float(0) }}"
        m00: "{{ states('sensor.shellypmminig3_84fce638860c_energy') | float(0) }}"
        ertag: "{{ m00 - m60 }}"
        preis: "{{ states('sensor.t_solar_preis') | float(0) }}"
        wert: "{{ preis * ertag }}"
  sensor:
    - name: Solar Zaehler
      unique_id: t_solar_zaehler
      device_class: energy
      unit_of_measurement: "kWh"
      state: "{{ m00 }}"
      attributes:
        m00: "{{ m00 }}"
        m60: "{{ m60 }}"
    - name: Solar Ertrag
      unique_id: t_solar_ertrag
      device_class: energy
      unit_of_measurement: "kWh"
      state: "{{ ertag }}"
    - name: Solar Wert
      unique_id: t_solar_wert
      state: "{{ wert }}"
      unit_of_measurement: "Eur"

Thank you once more. Again it is you with the most helpful answer. I have never used (or even known how to use) variables before, but your example is very clear. So a list of variables can be relied on to stick to the order they’re written? I don’t need to split it up into a sequence of actions? Just to absolutely sure.
Danke