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

Javascript sort misuse #26

Open
ozomer opened this issue Aug 23, 2019 · 0 comments
Open

Javascript sort misuse #26

ozomer opened this issue Aug 23, 2019 · 0 comments

Comments

@ozomer
Copy link

ozomer commented Aug 23, 2019

https://github.com/tehnokv/picojs/blob/master/lploc.js#L110-L111

Classic "javascript gotcha". The default sort compares the string values, not number values.
[1, 10, 2].sort() will result in [1,10,2].
I'm almost sure this was not the purpose...
Please use sort((a,b) => a-b)

@ozomer ozomer changed the title Javascript sort misusage Javascript sort misuse Aug 23, 2019
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

1 participant