std.algorithm range violation

Wanderer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 28 03:53:12 PDT 2014


On Wednesday, 28 May 2014 at 10:10:41 UTC, maarten van damme via
Digitalmars-d-learn wrote:
> an anyone explain me what I'm doing wrong here :
>
> [code]
> dstring[][dstring] providor_symbol_map;
> ...
>
> writeln(providor_symbol_map.keys.sort!((x,y)=>providor_symbol_map[x].length>=providor_symbol_map[y].length));
> [/code]
>
> output:
> core.exception.RangeError at std.algorithm(9429): Range violation

"dstring[][dstring]" declaration looks a bit obscure to me...
what do you intent with it, "array of maps" or "map of arrays"?

Also, it looks unnatural that inside sorting lambda, you refer
outside from it (back to providor_symbol_map variable). Ideally,
you should only use variables x and y. Does D support sorting by
map entries instead of by keys only or by values only?


More information about the Digitalmars-d-learn mailing list