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

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 9 19:39:12 PST 2014


On 11/9/14 4:49 AM, "Nordlöw" wrote:
> On Sunday, 9 November 2014 at 08:12:37 UTC, Andrei Alexandrescu wrote:
>> sortBy!(expr) is equivalent with sort!(expr_a < expr_b) so there's no
>> additional power to it. However, it does make some sorting criteria
>> easier to write. A while ago I took a related diff pretty far but in
>> the end decided to discard it because it didn't add sufficient value.
>
> What do you mean by sufficient value?

It seemed to me just another way of doing the same things.

> Ruby has sort_by. I believe D would when possible should be a superset
> of the union of powers available in other languages to maximize the ease
> of porting code *to* D and the pleasure for programmers to switch to D.

Sadly things don't work that way - e.g. Phobos1 took a bunch of string 
functions from Ruby and Python, to no notable effect.

> I'll try to make this elegant and useful and use it myself for a while.
> If it works for me I'll do a PR still. Ok?

That's a better approach, thanks. A few compelling examples would help.


Andrei



More information about the Digitalmars-d mailing list