I was searching for "how to sort multiple arrays at once" and found this question here: 
Sorting multiple arrays at once
And there a nice answer from Alexander solving my problem. But I don't fully understand this part from the answer right there: 
/* A shorthand function */
var comparator = function(arr) {
    return function(a, b) {
        return ((arr[a] < arr[b]) ? -1 : ((arr[a] > arr[b]) ? 1 : 0));
    };
};
Could someone explain me what this part of his code does?
 
     
     
    