in webinar 08 at 1:30:10 output is not coming as expected
let arr=[6,3,9,1,7,2,14,26,35]
function compare(a,b){
return b-a;
}
arr.sort( function(a,b) {
console.log(arr)
console.log(a+" "+b)
return a-b;
} )
console.log(arr)
chrome console o/p
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
6 3
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
6 9
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
9 1
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
6 1
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
3 1
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
9 7
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
6 7
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
9 2
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
7 2
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
6 2
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
3 2
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
1 2
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
9 14
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
14 26
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
26 35
[ 1, 2, 3, 6, 7, 9, 14, 26, 35 ]
final answer is sorted but i can’t see step by step sorting process
also console.log(a+" "+b) <— in chrome console 6 3 gets printed but in vs code 3 6. why so
console.log(arr)
[ 6, 3, 9, 1, 7, 2, 14, 26, 35 ]
6 3
VS CODE o/p[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
3 6
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
9 3
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
9 6
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
1 6
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
1 3
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
7 6
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
7 9
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
2 6
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
2 3
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
2 1
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
14 6
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
14 9
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
26 6
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
26 9
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
26 14
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
35 7
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
35 14
[
6, 3, 9, 1, 7,
2, 14, 26, 35
]
35 26
[
1, 2, 3, 6, 7,
9, 14, 26, 35
]