2 ms·
Thanks for the clarification! When I first learned about hash tables (in Perl), the book I used said that the iteration order over a hash should never ever be
by krylon 8y ago
Thanks for the clarification!
When I first learned about hash tables (in Perl), the book I used said that the iteration order over a hash should never ever be relied upon, and that it could change arbitrarily from one release to the next. If the order mattered, one should use a different approach (get the keys and sort them by whatever criteria), plain and simple. I guess that has sunk in pretty deeply with me. ;-)
The .Net framework provides an OrderedDictionary and a SortedDictionary, both of which make some kind of promise regarding iteration order, but I have never used them myself.