Open ben-albrecht opened 5 years ago
I think something like domain(keyType, ordered=true)
would be a sufficient addition to the associative domain argument-list. As well, it would be ncie to be able to sort
an associative array and associative domain.
var D : domain(string, ordered=true);
var.A : [D] int;
D += "A";
D += "C";
D += "B";
writeln(D); // A C B
A["A"] = 3;
A["B"] = 1;
A["C"] = 2;
writeln(A); // 3 2 1
sort(D);
writeln(D); // A B C
writeln(A); // 3 1 2
sort(A);
writeln(D); // B C A
writeln(A); // 1 2 3
This issue tracks the desire for some kind of ordered associative arrays / dictionary. This is where the order in which elements are added is maintained even after removal or resizing.
One approach to supporting this is by making associative arrays ordered by default, which is discussed as a potential solution to #8339.