Sort Associative Array by Key
a11e99z
black80 at bk.ru
Sun Aug 25 17:01:23 UTC 2019
On Sunday, 25 August 2019 at 16:54:33 UTC, Samir wrote:
> Is there a way to output the values of an associative array
> based on the lexicographic order of the keys?
>
> For example, if foo = ["VXE":8, "BZP":5, "JLC":2], I'd like to
> output something like:
>
> 5
> 2
> 8
>
> auto foo = ["VXE":8, "BZP":5, "JLC":2];
> foo.byPair.array.sort!"a[0]<b[0]".map!"a[1]".writeln;
More information about the Digitalmars-d-learn
mailing list