Skip to content

Stabilize SlickGrid sorting #85

@vyznev

Description

@vyznev

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions