StackExchange.DataExplorer icon indicating copy to clipboard operation
StackExchange.DataExplorer copied to clipboard

Stabilize SlickGrid sorting

Open vyznev opened this issue 7 years ago • 0 comments

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:

vyznev avatar Mar 06 '18 19:03 vyznev