Generates comparator functions to be used with Array.prototype.sort (and its implementations).