On Tue, Jan 25, 2022 at 12:23:40AM +0000, forkit via Digitalmars-d-learn wrote: > 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)
AA's are unordered containers. Do not rely on entries to appear in any specific order when you traverse an AA; it is implementation-dependent and may differ from OS to OS / platform to platform / sequence of operations performed on the AA since its initialization / phase of the moon. Any specific order that may appear in an AA is pure coincidence and may not appear again next time, or may only appear again at 11:59:59 Feb 29 under a blue moon. If you need entries in your AA in a specific order, extract them (or their keys) into an array then sort them yourself. E.g.: string[string] myAA; auto keys = myAA.keys; sort(keys); foreach (k; keys) { ... // now keys will be in the expected order } T -- Freedom of speech: the whole world has no right *not* to hear my spouting off!