Open Klaestrup opened 1 month ago
It certainly does. I'll take a look.
@Klaestrup: Can you confirm that you have non-numeric characters in the states, such as units of measurement? Can you provide a pair of strings that are sorting incorrectly?
I'm using counter values, to show repeating tasks/reminders:
entities: include: counter.reminder*
sort_by: state+
And the values are shown like this:
I was thinking of using flex-table-card instead of template-entity-row, but I'm missing the tap_action feature here. Is it possible somehow to preset the counter to its initial value with a push on the row? In template-entity-row I'm using the confirmation text, so that you have to confirm that it's the correct counter that you want to preset.
As I suspected, it's the non-numeric text "dage" that causes the failure--the algorithm does not treat the value as numeric. I have a fix for this problem, which I could provide to you while we wait for the code owner to respond to pull requests. But if the component doesn't meet your needs in other ways it may not be worth your trouble.
There has been some discussion about adding actions to the component, but nothing has been done yet.
But 'dage' is not a part of the state, but a suffix (suffix: ' dage'). Then I don't expect that it's sorted on this also...?
OK, I thought you were using auto_format. You are correct: suffix is not part of the sort.
Do you mind posting your entire card config?
Here it is, but I don't know how to post it correctly. The "Code" button does not support YAML! :-p
type: custom:flex-table-card title: Opgaver sort_by: state+ clickable: true entities: include: counter.reminder* card_mod: style: | div { padding: 4px; } css: table+: 'border-collapse: collapse;' th+: 'padding: 8px;' td+: 'padding: 16px;' columns:
<span style="color:red;">${x}</span>
;
} else if (parseFloat(x) === 0) {
x = <span style="color:yellow;">${x}</span>
;
}
x;
Just paste it, select all, press the Code
button:
type: custom:flex-table-card
title: Opgaver
sort_by: state+
clickable: true
entities:
include: counter.reminder*
card_mod:
style: |
div {
padding: 4px;
}
etc.
So your issue is essentially the same as #129. Your HTML or anything added by modify
becomes part of the sort, and is no longer treated as a numeric but as text. I will see if I can get a PR pushed through to deal with it.
If the state can be both plus or minus, it sorts the minus values in the wrong order (like it was plus values).