I have an array that contains values like this:
var testSorting = [0,null,1,0,1,null];
When I sort it like this:
testSorting.sort()
then the output is [0, 0, 1, 1, null, null]
But if I do it like this:
testSorting.sort(function(a, b){
return a-b;
});
console.log(testSorting);
the output is [0, null, 0, null, 1, 1].
I don't know why the result is like this. I need the result to be like the first method.