Sort method question

How does this code work? What do a and b stand for or represent?

function ascendingOrder(arr) {
  return arr.sort(function(a, b) {
    return a - b;
  });
}
ascendingOrder([1, 5, 2, 3, 4]);

Thanks,

Andrej

Hello there @andrejjj222,

I would explain this, but someone else have explained this better on this topic:

1 Like