Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Sorting items in a collection


Message #1 by "Nikolai Devereaux" <Nikolai@u...> on Fri, 27 Jul 2001 14:34:29 -0700
The Add method of the collection object has the following format:
     CollObject.Add NewItem, Key, Before, After
This lets you insert an new item in any place you want using the before and
after named parameters.

In a collection class the Add function should take advantage of this if you
want to keep the collection sorted. You have to write some code to determine
where to insert the new item. For my experience if you have a large number
of items and the new items are added at random places you should code a
binary search. In other cases a secuential search would be enough.


Daniel Weigel
Ciudad de la Costa
Uruguay

-----Mensaje original-----
De: Nikolai Devereaux [mailto:Nikolai@u...]
Enviado el: Viernes, 27 de Julio de 2001 06:34 p.m.
Para: professional vb
Asunto: [pro_vb] Sorting items in a collection


Is there a built in method in VB to sort items in a collection based on a
particular field or property of those items?

I can't seem to manually modify the "index" property... but I'm adding
objects into a collection and need to keep them sorted a certain way.


  Return to Index