>Hi Tamar,
>
>Am liking working with collections! Paper was also helpful.
>
>One thing I ran into that I could not solve was that I wanted to sort the collection after it had been assembled - I looked at putting an index key with each item in the collection but unfortunately in this situation, I do not know the key until after the collection has been created (it is a collection of objects and the key that I could use comes at a later stage in the process).
>
>It seems there is no way to update a key after the fact so what I had to do was to throw all the objects into an array, put my key into the 2nd column of the array, sort the array and then move the objects back into a new collection. It works but doesn't seem optimal. Thankfully it will only ever be a small collection of 20 to 30 objects. I don't really notice any big hit on performance.
>
>Albert
Did you take a look at the eBefore and eAfter parameters of the Add method?
for example:
loCollection = createobject('Collection')
loCollection.Add('abc', '_123')
? loCollection.Item(1)
loCollection.Add('def', '_345', '_123')
? loCollection.Item(1)
? loCollection.Item(2)
Another property that might help you is KeySort 0 - by index, 1 - by index desc, 2 - by key, 3 - by key desc
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges