[go: up one dir, main page]

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

CompareNatural does not compare strings lexically. #1121

Closed
harrysarson opened this issue May 31, 2018 · 1 comment
Closed

CompareNatural does not compare strings lexically. #1121

harrysarson opened this issue May 31, 2018 · 1 comment

Comments

@harrysarson
Copy link
Collaborator
harrysarson commented May 31, 2018

CompareNatural uses javascript-natural-sort to compare strings.

Strings are not compared lexically as the docs say they should be.

For example:

> math.compareNatural('5', '10')
-1
> '5' < '10'
false

and

> math.compareNatural('10/11/2009', '10/12/2008')
1
> '10/11/2009' < '10/12/2008'
true

Is this a bug or should we change the docs to say something like strings are compared in a sensible way?

(Note that the javascript operator < does lexical comparison on strings)

josdejong added a commit that referenced this issue May 31, 2018
…ural` and clarified the behavior for strings
@josdejong
Copy link
Owner
josdejong commented May 31, 2018

Thanks, it's indeed an error in the documentation. I've updated the docs, see a389d34.

For reference, see also #1065.

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

2 participants