assoc. array sort or preserve order

2010-09-10 Thread Dr. Smith
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) { wr

Re: assoc. array sort or preserve order

2010-09-10 Thread Jesse Phillips
Dr. Smith Wrote: > Is there a way to preserve an array's original order, or to sort an assoc arr > by key? No, Associative arrays can not preserve this for performance reasons. Though you can do the following. import std.algorithm; import std.stdio; void main() { double [string][string] val