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

Comments

Projects
None yet
2 participants
@harrysarson
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

Fixed #1065, #1121: Fixed wrong documentation of function `compareNat…
…ural` and clarified the behavior for strings
@josdejong

This comment has been minimized.

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.

@josdejong josdejong closed this May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment