Andrei Alexandrescu <[email protected]> wrote:

> Heh, thanks. I reckon doing the equivalent for pointers would require
> some unsavory manipulation.
> 
> Andrei

You may want you check Python's "cmp_to_key" function. In terms of D it
would be like:

struct CmpToKey(alias binaryPred, T) {
  int opCmp(other) { return binaryPred(this, other); }
  T wrapped;
}

Then sort/min/max by `cmpToKey!"a<b"(a)`.

Reply via email to