What's Wrong with JavaScript sort() Function 🤔
This year I decided to solve the famous Advent of Code Challenge in both Python and JavaScript. I’m also gonna be posting my solutions on my GitHub repository. And while solving today’s advent of code challenge, in javascript. I came across a weird behaviour of the sort() function in javascript. I was trying to sort an array of numbers, and I was using the sort function like this: const myArray = myArray.sort(); then I console.log()ed it to see the result, and it was sorted in ascending order. But when I tried to sort it in descending order, it didn’t work. I tried to do this: ...