Languages

JavaScript - array sort() method doesn't work properly

3 points
Asked by:
mkrieger1
726

Could you tell me why JavaScript doesn't sort the array of a numbers correctly?

My code:

1 answer
3 points
Answered by:
Admin Dirask Community
4380

It's because JavaScript sorts arrays alphabetically.

Check out our article: JavaScript - sort array.

This should solve your problem:

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join