I am new to javascript and I was solving a puzzle on checkio, there I encountered an Array(unsorted) that needs to be sorted before proceeding further but its not working as expected.
below is the array and the array after sorting it using Array.sort().
let arr = [ 3, 6, 20, 99, 10, 15 ];
when I do the arr.sort()
, I am getting the result as shown below
[ 10, 15, 20, 3, 6, 99 ]
whereas it should be [3,6,10,15,20,99]
I tried the same in my node command line console and as well as google chrome's console but getting the same output.
can anyone help me with it?
Thank You.