Closed bbbenji closed 5 years ago
I believe this is a data-type issue. Means you have to make sure that the data is properly converted to a number. This depends on the origin of your data and how it is represented there.
To solve this you can make use of modify
to parse the data to the designated data-type, in this case I would propose something like this:
...
columns:
- prop: state
name: Time
modify: parseFloat(x)
Now sort_by
should work as expected, take a look into issue #7 to see another similar example.
I can confirm parseFloat(x) solves the problem. Thanks for the hint.
I now have hard time getting proper number formatting with parseFloat(). Using .toFixed(3) results in bad sorting again. I tried adding and hiding a column for sorting purposes but then it turned out hidden: true does not work properly. It hides column title, but does not hide its values.
Nevertheless, I really appreciate your work. It's a really useful card that you've made.
oh no, this is obviously a bug, but can likely be easy fixed, let's see if I can solve this this evening. Despite that if you would like to use toFixed() the number is coverted to a string again, thus not numerically sortable, other sorting mechanisms (i.e., table viewer tools, fileexplorer) usually implement a "natural" sorting instead of the formal sorting applied here, this might be a solution also to avoid this whole hassle.
In the meantime the best way would really be the hidden flag, looks like I broke during the recent feature-hunt commits, but should be easy... will keep you updated....
2 lines fix, couldn't resist.
thanks for pointing this out, hopefully I did not introduce a new bug,
but hidden: true
at least will hide the header and the contents again.
Now it’s perfect. Glad it was a simple fix. Thanks again!
Then I'll close this issue, don't hesitate to find new bugs :D And if you're building a nice table and you think it would be good as an example, feel free to share...
I am displaying a list of entities and their states and sorting by state. Whenever an entity hits 2 digits, it seems that this card only takes the first digit into account for sorting.
As soon as that first entity hit a state of 9, it popped to the bottom of the list.
config: