sortOn: sorts range of aggregates by member name(s)
via Digitalmars-d
digitalmars-d at puremagic.com
Wed Nov 5 06:36:08 PST 2014
On Wednesday, 5 November 2014 at 14:07:10 UTC, Nordlöw wrote:
> On Wednesday, 5 November 2014 at 11:18:56 UTC, Marc Schütz
> wrote:
>> This could also be an arbitrary expression, of course:
>>
>> r.sortBy!"x*x + y*y + z*z"
>>
>> The above could be implemented using `with` and
>> `std.functional.unaryFun`. Alternatively, a lambda could be
>> used:
>>
>> r.sortBy!(a => a.norm);
>
> Ok. Great. What do you think about the name sortBy?
It's intuitive and concise. Plus, Ruby uses `sort` and `sort_by`
for the same functionality, exactly in parallel, so it will be
familiar to many users.
More information about the Digitalmars-d
mailing list