Sort Associative Array by Key

a11e99z black80 at bk.ru
Wed Aug 28 07:37:50 UTC 2019


On Tuesday, 27 August 2019 at 20:35:16 UTC, bachmeier wrote:
> On Tuesday, 27 August 2019 at 20:14:21 UTC, Machine Code wrote:
>
>> It isn't really hard:
>
> It really is hard. foo.byPair.array.sort!((a, b) => a.key < 
> b.key).map!(a => a.value); is a lot to digest for someone 
> learning the language. There's a big difference between not 
> being hard for someone that understands what each piece does 
> and not being hard for someone new to D. At a minimum, it would 
> help to write it
>
> foo.byPair
>  .array
>  .sort!((a, b) => a.key < b.key)
>  .map!(a => a.value);

I wrote expression with string lambdas for one purpose:
when u see very simple beauty thing that is working and u totally 
doesn't understand how exactly, ur curiosity should do the rest 
of the work. it's worth sorting out.
if man wanted just do his job, he got this too.


More information about the Digitalmars-d-learn mailing list