Iterate/sort associative array by value?
Robert M. Münch
robert.muench at saphirion.com
Sun Apr 7 18:22:00 UTC 2019
On 2019-04-07 17:16:12 +0000, Seb said:
> Then you can do:
>
> ---
> ["a": 1].byPair.array.sort!((a, b) => a.value < a.value).release.each!writeln;
> ---
>
> You'll have a sorted array with key and value props.
This seems to be really tricky:
int[uint] myArray;
foreach(key, value; myArray.byPair.array.sort!((a, b) => a.value <
a.value)){...}
Error: no property sort for type Tuple!(uint, "key", int, "value")[]
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d-learn
mailing list