JavaScript's Array.sort() doesn't sort numbers the way you expect. Learn why the default string conversion causes lexicographic ordering, see the classic [10, 2, 1] bug in action, and fix it with a one-line comparison function.
Practice answering this question with AI feedback: https://interviewmentor.app?utm_sourc...
On this page of the site you can watch the video online Why JavaScript sort() Breaks with Numbers with a duration of hours minute second in good quality, which was uploaded by the user Interview Mentor App 25 February 2026, share the link with friends and acquaintances, this video has already been watched times on youtube and it was liked by 0 viewers. Enjoy your viewing!