assoc. array sort or preserve order

Dr. Smith iam at far.out
Fri Sep 10 14:27:29 PDT 2010


Is there a way to preserve an array's original order, or to sort an assoc arr
by key?
With code like the following, the values of the string indices allow foreach
to needlessly re-order the array:
...
double[string][string] val;
...
foreach(string1, row; val) {
  foreach(string2, col; row) {
    writefln("%s\t%s\t%f", string1, string2, col);
  }
}

One possible way to control ordering is to add an index, like
double[int][string][string] where the int is an index.  However, I haven't yet
overcome the compiler's problem with the int.


More information about the Digitalmars-d-learn mailing list