std.algorithm range violation
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed May 28 10:39:13 PDT 2014
On Wednesday, 28 May 2014 at 11:40:05 UTC, Wanderer wrote:
> Sorry about typo, I meant
>
> providor_symbol_map.sort!((x,y)=>{x.value.length>y.value.length})
>
> above.
providor_symbol_map is an Associative Array, so you can't sort
that. *Usually*, you want to do what the OP did, which is to get
the keys, and sort them, but leave the AA unchanged. EG:
Val[Key] myAA;
Key[] mySortedKeys = myAA.keys.sort!((x, y)=> compare(myAA[x],
myAA[y]))()
//Print values in incremented order:
foreach(key; mySortedKeys)
writefln("%s: %s", key, myAA[key]);
More information about the Digitalmars-d-learn
mailing list