Allow to pass a function for selecting the key that will be used for the sorting