sortWith package:ghc-internal

The sortWith function sorts a list of elements using the user supplied function to project something out of each element In general if the user supplied function is expensive to compute then you should probably be using sortOn, as it only needs to compute it once for each element. sortWith, on the other hand must compute the mapping function for every comparison that it performs.