I don’t understand numeric sort compare function. how to work it? [duplicate]

I don’t know how that is calculated?

instances:

const points = [40, 100, 1, 5, 25, 10];
points.sort(function(a, b){return a - b});

output: 1,5,10,25,40,100

output is okay. But how is it calculated?

I tried but I can’t match a and b equations