unordered output of an associated array of associated arrays
forkit
forkit at gmail.com
Tue Jan 25 00:23:40 UTC 2022
so I'm trying to understand why the output of the code below, is
in reverse order of the declaration (and how to fix it so that it
outputs in an ordered way)
i.e. output is:
typeA:
A2:A2value
A1:A1value
typeB:
B3:B3value
B2:B2value
B1:B1value
// --
module test;
import std;
void main()
{
string[string][string] aaTable =
([ "typeA" : ["A1" : "A1value", "A2" : "A2value"],
"typeB" : ["B1" : "B1value", "B2" : "B2value", "B3" :
"B3value"]
]);
foreach (topLevelKey, topLevelValue; aaTable.byPair)
{
writefln("%s:", topLevelKey);
foreach(key, value; topLevelValue)
{
writefln("\t%s:%s", key, value);
}
}
}
//--
More information about the Digitalmars-d-learn
mailing list