A way via functions to reverse the order of an array, using .sort() (need help explaining solution) [duplicate]

I’m new to javascript – I just had a problem that asked me to find a way via functions to reverse the order of an array of years, using .sort(). After flailing for a bit, I checked the answer and received the one below:

const sortYears = arr => arr.sort((x, y) => y - x);

I have no idea how someone would get this, or where the x and y come from.

I tried using sort() and nesting Collections.reverseOrder() as suggested in another answer to a similar question, but kept receiving errors.