Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ordering is not correct for ordinal (string) keys #1690

Closed
gordonwoodhull opened this issue Jun 26, 2020 · 0 comments
Closed

ordering is not correct for ordinal (string) keys #1690

gordonwoodhull opened this issue Jun 26, 2020 · 0 comments

Comments

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Jun 26, 2020

We removed crossfilter.quicksort in #1560 but the way we implemented it using Array.sort() is only compatible with numbers, not with strings.

I was looking at how hard it is to implement ordinal bar transitions for a question on SO. It's not hard, but the ordinal transition tests that modify the ordering were not working.

In order to work with both strings and numbers,

Array.from(data).sort((a, b) => { return _ordering(a) - _ordering(b) })

should be

Array.from(data).sort((a, b) => d3.ascending(this._ordering(a), this._ordering(b)))

so that it does not return NaNs (which effectively disable ordering).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant