Re: In what order are dict values returned by "dict get"?



Adrian Davis wrote:
In what order are dict values returned by "dict get?"

I think you must mean [dict keys] or [dict values] there; [dict get]
itself only returns a single value.

Are they in apha order by keyname or is it random?

Officially random. Unofficially, it depends on a whole bunch of factors
including the history of the hash that backs the implementation. It's
quite difficult to characterize.

What you *can* be assured of is that:
foreach key [dict keys $d] val [dict values $d] {
puts "$key -> $val"
}
will print out matched pairs of values. What you can't be assured of is
what order they'll be in, other than that you'll get the same effect
from this:
foreach {key val} $d {
puts "$key -> $val"
}

Donal.

.



Relevant Pages