Expanded group: how to sort by attribute

There is a group of entities (binary template sensor).
Each entity has an attribute “battery_level”.
I need to get a list of entities sorted by this attribute:

{% set batteries_charging = expand('group.batteries_mobile_charging') %}
{% for battery in batteries_charging | sort(attribute="battery_level") %}
{{
  {
    'SENSOR_BATTERY_CHARGING': battery.entity_id,
    'LEVEL': state_attr(battery.entity_id,"battery_level")
  }
}}
{% endfor %}

But it does not sort by it:

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_ildar', 'LEVEL': 0.62}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_ildar_ipad_air', 'LEVEL': 0.85}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_ildar_ipad_mini', 'LEVEL': 0.76}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_irina', 'LEVEL': 0.29}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_mama', 'LEVEL': 0.37}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_mama_galina', 'LEVEL': 0.63}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_papa', 'LEVEL': 0.65}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_papa_boris', 'LEVEL': 0.49}

{'SENSOR_BATTERY_CHARGING': 'binary_sensor.battery_charging_life360_samsung_p6800', 'LEVEL': 0.68}

How can I sort it properly?

{% for battery in batteries_charging | sort(attribute="attributes.battery_level") %}

Thank you very much!