Why nums
array is not getting sorted? How does >
or <
operator works inside sort
method as in the below code?
const nums = [1, 2, 5, 45, 22, 48, 11];
console.log(nums); // [1, 2, 5, 45, 22, 48, 11]
nums.sort((a, b) => a > b);
console.log(nums); // [1, 2, 5, 45, 22, 48, 11]