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

Fix of the compare function #245

Merged
merged 1 commit into from
Feb 13, 2017
Merged

Commits on Feb 13, 2017

  1. Fix of the compare function

    The previous version of the compare function was not consistent (it did not follow the requirements on the compare function), see https://tc39.github.io/ecma262/#sec-array.prototype.sort for details. You can see that the compare function is not correct by using it to sort larger arrays. For example, if you sort the letters of a well known sentence:
    `"the quick brown fox jumps over the lazy dog".split('').sort((a,b) => a>b).join('')`
    returns `"uge d ac  be e  f otjhmpsnooqrothrkliuvwxyz"` on Node.js 6.7.0. While `"the quick brown fox jumps over the lazy dog".split('').sort((a,b) => a > b ? 1 : (a < b ? -1 : 0)).join('')` returns the correct result `'        abcdeeefghhijklmnoooopqrrsttuuvwxyz'`.
    iamstolis authored Feb 13, 2017
    Configuration menu
    Copy the full SHA
    0ad46f8 View commit details
    Browse the repository at this point in the history