Sort Entities in Apex Charts Donut Card

Hi,
is there a way to sort the entities in the apex chart donut card after their own value?
So the highest value comes first, the second highest value the second and so on

in home assistant I have not yet found a way

Please post a SHORT MINIMAL code for a doughnut card which you wish improve.

Here’s one of my donuts, what I seek is to have the slices in descending order whereas they occur in the entity’s list order by default

type: custom:apexcharts-card
chart_type: donut
apex_config:
  chart:
    height: 500px
  plotOptions:
    pie:
      donut:
        labels:
          show: true
          total:
            show: true
            label: Total
            formatter: |
              EVAL:function(w) {
                return (w.globals.seriesTotals.reduce((a, b) => a + b, 0) / 1000 * 1.05)
                  .toFixed(2)
                  .replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " kW";
              }
update_interval: 5sec
header:
  show: true
  show_states: true
  colorize_states: true
  standard_format: false
  title: Live power usage
series:
  - entity: sensor.sonoff_1000fd05e5_power
    name: DS Power
    color: rgb(255,0,0)
  - entity: sensor.sonoff_100169353e_power
    name: DS Light
  - entity: sensor.sonoff_1000fd021f_power
    name: US Power
  - entity: sensor.sonoff_1001694739_power
    name: US light
  - entity: sensor.sonoff_1000e7db7f_power
    name: Alfresco Oven
  - entity: sensor.sonoff_1001121739_power
    name: Alf L&F
  - entity: input_number.hws_power_watts_follower
    name: HWS
  - entity: sensor.sonoff_1001121a48_power
    name: Alf GPO3
  - entity: sensor.sonoff_1001121f94_power
    name: Alf GPO2
  - entity: sensor.sonoff_1001122101_power
    name: Alf GPO1
  - entity: sensor.sonoff_1000fcffe6_power
    name: DS Cooktop
  - entity: sensor.sonoff_10012c5536_power
    name: Kona
  - entity: sensor.sonoff_10009746cd_power
    name: Zoe
  - entity: sensor.hot_tub_power_watts
    name: Hot Tub
  - entity: sensor.sonoff_1001106294_power
    name: Leaf
    color: rgb(30,255,0)
  - entity: sensor.sonoff_10011218d2_power
    name: Alf DW/HWS/Fridge
  - entity: sensor.true_alfresco_ac_instant_w_rounded
    name: Alfresco A/C
  - entity: sensor.upstairs_cooktop_oven_power
    name: US Cooktop

SHORT MINIMAL code?

not here to advocate ChatGPT (not allowed), but this seems an easy task for that language model. I did get an answer and explanation, please try for yourself and see what happens?

Seems that “short minimal code” is something absolutely unclear and it is normal to lay out tons of own code as is.
The minimal is:

type: custom:auto-entities
card:
  type: custom:apexcharts-card
  chart_type: donut
  ...
card_param: series
filter: ...
sort:
  method: state

image

If you need more per-entry customizations like “name” etc - you will have to learn how to use a “template” option of auto-entities.

It does go down a rabbit hole unfortunately, I went there first before I replied to this thread.
I was hoping there was something available such as

sorting: yes
  method: descending

or similar

When I saw someone else asked, it peaked my interest to further the enquiry