[VB.NET] List.Sort based on Tag

You can use the IComparer interface to do this

The List class supports an overloaded version of the .Sort method that takes an input of type IComparer

Basically you need to implement IComparer in your class so that it does the comparison based on the tag of the object, then just sort the list using that IComparer.

This link should help out a bit
http://www.devx.com/dotnet/Article/21089/0/page/3
 
Last edited:
Haircut said:
You can use the IComparer interface to do this

The List class supports an overloaded version of the .Sort method that takes an input of type IComparer

Basically you need to implement IComparer in your class so that it does the comparison based on the tag of the object, then just sort the list using that IComparer.

This link should help out a bit
http://www.devx.com/dotnet/Article/21089/0/page/3

Sorry but i am new to VB.Net and i dont really understand the icomparer classs thingy.

I did some googling to no avail.

I understand what an Icomparer is but i just don't know how to implement one.

Specifically i dont understand where i should be putting this class, but i also don't understand how i would go about making the actual content of the class.

Has anyone got any good examples of its implementation
 
What object type are you storing in Tag? It all depends on this because if it already supports IComparer then you won't have to do much work at all.
 
Back
Top Bottom