-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix sort order in Chrome #1019
base: master
Are you sure you want to change the base?
fix sort order in Chrome #1019
Conversation
Default "comparer" function was returning unreliable result in Chrome, giving consistent but wrong sort order. Results in Firefox were correct.
what went wrong? I don't know of any scenario that would behave different in different browsers unless you hit the sort algorithm specifics which are not fixed in the JavaScript spec(s): |
http://jsfiddle.net/michalcarson/j8dcmxwx/ Just threw this fiddle together to compare the results of the two methods. I may have something whacked here because the result of the current comparator (a.value - b.value) is always coming up as NaN. That's not what I was expecting. But if that's correct, it's no wonder the sort is not working with that comparator. The data used is similar to the data my users were looking at when they complained about the order. The dataView will not put country names in the right order under Chrome. They sort correctly under Firefox. |
Aha. You're subtracting strings. The subtraction will attempt to coerce Your 'greater than' comparison does not suffer from the same 'must coerce I'd say this is browser specific, but what you observe is different This explains why the patch is working. Thanks for your response & jsfiddle. Thanks! a test run in the browser (Chrome) which shows this and other trouble with Also note the difference when comparing strings and numbers: the type browser test;
Met vriendelijke groeten / Best regards, Ger Hobbelt web: http://www.hobbelt.com/ mobile: +31-6-11 120 978http://jsfiddle.net/michalcarson/j8dcmxwx/ Just threw this fiddle together to compare the results of the two methods. The data used is similar to the data my users were looking at when they — |
…a-rowspan; see also mleibman#1019 mleibman#1019 Conflicts: slick.dataview.js
This has been integrated into my 'alternative master'. Any testing is appreciated. See #1055 |
Default "comparer" function was returning unreliable result in Chrome, giving consistent but wrong sort order. Results in Firefox were correct.