How to Sort an Array in JavaScript?
asked 229 days ago
0Answers
34Views
I'm working on a project where I need to sort an array of numbers in JavaScript. I've tried using the sort()
method, but it's not giving me the expected output. Here's a snippet of what I've tried:
const numbers = [5, 2, 9, 1, 5, 6];
numbers.sort();
console.log(numbers);