Ordering an associative array - or - another option
Jonathan M Davis
jmdavisProg at gmx.com
Wed Jun 6 10:05:24 PDT 2012
On Wednesday, June 06, 2012 16:04:14 Paul wrote:
> I have and array string[string][string][string] that works great
> for everything I need except that they (assoc. arrays) don't
> maintain an order. I need to maintain the order of entry.
>
> Are there any work arounds that others have used? I saw some
> tricks in the book for sorting a single dimensional assoc. array.
>
> Thanks to all!
If you want an ordered map, then use std.container.RedBlackTree. It's a little
bit annoying to use as a map (you basically have to use it as a set of
pairs/tuples which are ordered on their first member), but it's quite doable
(and is what C++'s STL does internally with std::map). Chaining them like you
seem to be trying to do though would probably get ugly though.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list