Andrei Alexandrescu:

> Obviously schwartzSort is one. Are there others?

max/min/mins/maxs come to mind immediately.
It's not too much hard to invent a more general decorate-function-undecorate 
higher order function, but I do not want to use it to do sort/max/min.


> I just figured an annoying case for sort through mapping: how would one 
> sort a range of ulong descending? Or a range of pointers for that matter?

Python sort has a optional boolean argument that allows you to specify if to 
sort ascending or descending, but this doesn't solve all cases.
Sorting a range of pointers is not a common operation, I presume.
A solution is to wrap the ulong inside a BigInt, but it's not efficient. In 
this case it seems better to use a comparison function instead.
My point wasn't to always replace comparison functions with a mapping one, both 
as useful in different situations. My point is that comparison functions are 
overrated, and both languages, standard libraries, and programmers need to take 
into account that mapping functions are often more handy, especially in the 
large percentage of a program where there is no need of top performance.

Bye,
bearophile

Reply via email to