plotly / dash-table-experiments

NO LONGER SUPPORTED - use https://github.com/plotly/dash-table instead
MIT License
174 stars 57 forks source link

Sorting on columns which include null values #58

Closed rileypeterson closed 5 years ago

rileypeterson commented 6 years ago

If null values exist in a column and an attempt is made to sort (either ascending or descending), the result should (IMHO) order the non null values first and place the null rows at the bottom. Instead sorting a column with null values yields inconsistent (random?) resulting order. Not sure I'm capable of fixing this on my own... otherwise I would

tomasfarias commented 6 years ago

I think the issue might be related to the fact that a function comparing a number with null will always return true if the comparison is greater than and will always return false if the comparison is less than.

Now this wouldn't be a problem if you passed the boolean vars to R.sort, however the the comparer function defined in sort.js actually returns 1 or -1. I made a fork and pull request in my own repo just to try a quick fix, replacing 1 for true and -1 for false, and, after adding a bunch of None in the DF_GAPMINDER defined in the example usage.py, it seems to be working (see images).

Not sure about the implications of this change, or even if my proposed solution is actually correct, which is why I haven't taken any steps to solve it in this repo.

image

image

alexcjohnson commented 5 years ago

This package is deprecated and about to be archived. The new package dash-table implements this correctly, also includes a way to allow '' (and soon likely other values) to behave as null.