What's the most efficient (in terms of speed) way to iterate over a
hash in sorted order of the keys? The keys are strings.

To use a balanced tree.
Hash can only ever be iterated in the hash order, which is fixed but
pseudo-random.

Well, here's my exact problem: I have a TreeMap that I add (string,
string) pairs to. The desired output is a sorted list of these pairs.
Now I'm wondering if it'd be more efficient to use a HashMap instead,
since I don't really need to maintain the sorted property as the list
is built up, just have it sorted when I return it. Roughly, I want
for i in map.keys.sort() {
retval.append (i, map[i])
}
return retval
except I've been through the API and I can't find a good way to sort
the keys, or to push the pairs into a list and sort the list.
martin