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

Local special characters are sorted wrong when sorting columns. Please change to localeCompare() #982

Closed
SKPFCW opened this issue Apr 21, 2021 · 3 comments
Labels

Comments

@SKPFCW
Copy link

SKPFCW commented Apr 21, 2021

German umlauts appear after sorting at the end of the list instead of in their correct place.
JavaScript localeCompare-Method should be used instead of greater/less-comparison.

For example:
Correct sorting would be:
Am, An, Ao, , Ap, Aq

Wrong sorting in jqGrid is:
Am, An, Ao, Ap, Aq,

The error occurs in the function this._compare by using binary greater-/less-than comparison: (Versions 5.5.4 and before)

529: this._compare = function (a, b, d) {
...
552:     if (a <b) {return -d;}
553:     if (a> b) {return d;}
554:     return 0;

Hotfix by using the JS localeCompare()-method:

552:-3     if (typeof a === "string") {
552:-2         return a.localeCompare(b) * d;
552:-1    } else {
552:             if (a <b) {return -d; }
553:             if (a> b) {return d; }
554:             return 0;
554:+1    }
@tonytomov
Copy link
Owner

I have fixed the problem. You can check it. Please let me know if it is ok for you.

@SKPFCW
Copy link
Author

SKPFCW commented Apr 21, 2021

It works great. Thank you for your quick and helpful support.

@tonytomov
Copy link
Owner

I will close the issue. Feel free to reopen it, if there is a problem

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

No branches or pull requests

2 participants