www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is an int[int] associative array always sorted?

reply Francis <Francis_member pathlink.com> writes:
Hello, D guys!

Is an integer-indexed associative array always sorted in a foreach loop?

-Francis
Feb 19 2005
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
I don't believe it is.  This was discussed earlier, actually, and you 
can use:

foreach (int key; array.keys.sort)
    array[key];

Or similar.  I'm pretty sure the order, unsorted, would be 
implementation-specific and shouldn't be depended on....

-[Unknown]


 Hello, D guys!
 
 Is an integer-indexed associative array always sorted in a foreach loop?
 
 -Francis
 
 

Feb 19 2005