On Tuesday, 25 January 2022 at 00:43:07 UTC, forkit wrote:

oh. thanks :-)

I will get that integrated into my example code, and will post again, once it's working (so others can learn too)

ok.. so I took the easy way out ;-)

output is now ordered:

typeA:100000003:[1, 1, 1, 0, 0, 0, 0, 0]
typeA:100000004:[1, 1, 1, 1, 0, 0, 0, 0]
typeA:100000005:[1, 1, 1, 1, 1, 0, 0, 0]
typeB:100000001:[1, 0, 0, 0, 0, 0, 0, 0]
typeB:100000002:[1, 1, 0, 0, 0, 0, 0, 0]
typeC:100000006:[1, 1, 1, 1, 1, 1, 0, 0]
typeC:100000007:[1, 1, 1, 1, 1, 1, 0, 0]


// --
module test;

import std;

void main()
{
    auto aaTable =
      ([
       "typeB" : [ 100000002 : [1, 1, 0, 0, 0, 0, 0, 0],
                   100000001 : [1, 0, 0, 0, 0, 0, 0, 0]
                 ],
       "typeC" : [ 100000007 : [1, 1, 1, 1, 1, 1, 0, 0],
                   100000006 : [1, 1, 1, 1, 1, 1, 0, 0]
                 ],
       "typeA" : [ 100000005 : [1, 1, 1, 1, 1, 0, 0, 0],
                   100000003 : [1, 1, 1, 0, 0, 0, 0, 0],
                   100000004 : [1, 1, 1, 1, 0, 0, 0, 0]
                 ]
      ]);

    string[] orderedKeyPairSet;

    foreach (key, pair; aaTable.byPair)
    {
        foreach(k, p; pair.byPair)
orderedKeyPairSet ~= key ~ ":" ~ k.to!string ~ ":" ~ p.to!string;
    }

    orderedKeyPairSet.sort;

    foreach(s; orderedKeyPairSet)
        writeln(s);

}

// ---

Reply via email to