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

Default sorting by string values has changed from case-insensitive to case-sensitive #1795

Closed
basvandenberg opened this issue Jul 31, 2017 · 3 comments

Comments

@basvandenberg
Copy link

I'm submitting a ...

[x ] bug report
[ ] feature request
[ ] support request

Current behavior
Currently (after updating from v8 to version v12) sorting rows by string values is by default case-sensitive, so a column with values: "a", "B", and "c", will be sorted as:

  • B
  • a
  • c

Expected behavior
I'm not sure what the specified behavior is, but in version 8 the default string sort was case insensitive, resulting in the following order:

  • a
  • B
  • c

What is the motivation / use case for changing the behavior?
The default sorting behavior seems to have changed. Since I could not find anything about this in the release notes* I thought this might have happened unintentionally.

The change seems to be introduced in this commit, where the default localeCompare is replaced with a doQuickCompare function.

Or should the 'accentedSort' be used for case insensitive sort? In which case it would be nice to have this mentioned in the documentation.

* I updated from 8 to 12, so I had to go through quit some release notes and might have missed this.

Please tell us about your environment:

  • ag-Grid version: 12.0.1

  • Browser:
    All

@ceolter
Copy link
Contributor

ceolter commented Aug 1, 2017

this was done on purpose, to allow for quicker comparing when you don't get impacted by case.

to have it work as previous, attach your own 'default' comparator to the default col def, ie:

gridOptions = {
  defaultColDef = {
      comparator: function(a,b) {
          if (typeof a === 'string') {
               return a.localCompare(b);
          } else {
               return (a > b ? 1 : (a < b ? -1 : 0));
          }
      }
  }
  ...
}

@ceolter ceolter closed this as completed Aug 1, 2017
@petyosi
Copy link
Contributor

petyosi commented Aug 9, 2017

The snippet from @ceolter above contains a typo ( localCompare -> localeCompare).

gridOptions = {
  defaultColDef = {
      comparator: function(a,b) {
          if (typeof a === 'string') {
               return a.localeCompare(b);
          } else {
               return (a > b ? 1 : (a < b ? -1 : 0));
          }
      }
  }
  ...
}

@ISkomorokh
Copy link

GridOptions now has a property accentedSort for this.

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

4 participants