sortOn: sorts range of aggregates by member name(s)

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 10 12:28:43 PST 2014


On 11/10/14 11:58 AM, "Nordlöw" wrote:
> On Monday, 10 November 2014 at 03:38:49 UTC, Andrei Alexandrescu wrote:
>> That's a better approach, thanks. A few compelling examples would help.
>>
>>
>> Andrei
>
> One more thing. How should reverse sorting be handled in elegant way?
> Like this
>
> https://github.com/nordlow/justd/blob/master/sort_ex.d#L57
>
> or via some other clever solution I haven't thought about?

For most numeric cases having the caller negate the key should suffice. 
For string types you'd need a separate function or fall back to classic 
sort. This, too, doesn't bode well for the power/weight ratio of sortBy. 
-- Andrei


More information about the Digitalmars-d mailing list