I needed to get a unique list of names.
I used a dictionary to build this list.
I used d.keys to get the list back.
I need to be sure the list is in the order in which the names were added.
It indeed is.
I’m surprised.
I thought it might be sorted.
Order is not guaranteed. If there is no value associated with the keys, I suggest you store the index to so you can restore the order yourself, if that’s what you need.
dim d as new dictionary
//values are order added.
d.value("Brian")=0
d.value("Andrew")=1
keys = d.keys
How do I now ensure the order as by the value?
dim values() as integer
values = d.values
for i=0 to values.ubound
print keys(values(i))
// val = d(i) //???
next i
This seems a bit inefficient.
How do I know that the values are not re-ordered by the keys…
stuff the indexes in one array & the names in another & use sort with
just use the dictionary to store the keys, not the data.
In other words (in pseudo code):
iterate over your list
if the item does not exist in the dictionary
append it to the outgoing array
add it to the dictionary
end if
apparently one cannot edit posts?
My previous post lost it’s light formatting. here it is again:
iterate over your list
if the item does not exist in the dictionary
append it to the outgoing array
add it to the dictionary
end if