[Haskell-cafe] Dynamically altering sort order

Martijn van Steenbergen martijn at van.steenbergen.nl
Fri Apr 24 17:27:23 EDT 2009

Denis Bueno wrote:
> The problem here is that the order is fixed.  Statically.  I can't
> change it at runtime based on flags.  (Right?  Unless I'm missing
> something....)

That is right. It might or might not be a problem in your specific case.

>> sortBy :: (a -> a -> Ord) -> [a] -> IO [a]
>> sortBy cmp = map unCR . sort . map (CompareRecord cmp)
> Right, that's what I was thinking, too.  The asymmetry was giving me
> the willies, though. =]

Yeah, I know what you mean; it doesn't feel very elegant. :-) I'm 
curious if anyone else has any neat ideas.


More information about the Haskell-Cafe mailing list