I saw this piece of code inside a JS book, but don't quite understand what is happening. Can someone explain it?

```
var values = [ 213, 16, 2058, 54, 10, 1965, 57, 9 ];
values.sort(function(value1,value2){ return value2 - value1; });

```

It seems like the sort is just taking in the difference of 2 values, yet it returns the sorted array. What is happening behind the scene?