Key and value with ranges

Joel joelcnz at gmail.com
Mon Oct 2 20:20:44 UTC 2023


On Monday, 2 October 2023 at 06:19:29 UTC, Imperatorn wrote:
> On Monday, 2 October 2023 at 02:47:37 UTC, Joel wrote:
>> ```d
>> import std;
>>
>> auto data=“I went for a walk, and fell down a hole.”;
>
> You can improve it further by inlining
>
> ```d
> import std;
>
> auto data = "I went for a walk, and fell down a hole.";
>
> void main(string[] args)
> {
>     int[string] dic;
>
>     data.split(' ').each!(w => dic[w]++);
>     sort(dic.keys).each!(w => writeln(dic[w], " ",w));
> }
> ```

I want the output sorted by value.


More information about the Digitalmars-d-learn mailing list