Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Stabilize SlickGrid sorting #85

Open
vyznev opened this issue Mar 6, 2018 · 0 comments
Open

Stabilize SlickGrid sorting #85

vyznev opened this issue Mar 6, 2018 · 0 comments

Comments

@vyznev
Copy link

vyznev commented Mar 6, 2018

The current implementation of client-side sorting (see issue #19) uses the native JS .sort() method, which is not stable in some browsers (such as, notably, Chrome). This can lead to weird behavior when sorting by a column that contains duplicate values, as shown e.g. in this animation.

There's a couple of possible ways to fix this:

  1. Change the SlickGrid data sorting code to use a custom stable sort method, as suggested in this article.
  2. Just flat out replace Array.prototype.sort with a stable reimplementation. Here's a suitable drop-in replacement that I've written and added to SOUP.
  3. Modify the sort comparator callback to use the current order of the rows as a tie breaker if the compared values are equal. This would be the simplest solution if the previous position of the rows is easily accessible in the comparator, which I'm not sure about.

See also:

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

No branches or pull requests

1 participant