Hi Dear,
I have one query. I have one arraylist in which i stored sturct object values now
i want to sort arraylist using struct object.
so plz help me.
Thnx
How sort arraylist if arraylist stored struct object
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted Oct 8, 2008, 1:13 AM EDT
You first need to create a helper class which implements IComparer and code its Compare() method to provide a sort order for your structs. This method should return the following int values when two structs, x and y, are compared to each other:
Less than zero
if x is less than y.
Zero
if x equals y.
Greater than zero
if x is greater than y.
You then need to create an instance of this class and pass it to the overload of ArrayList.Sort() which takes an IComparer parameter. See the MSDN example below (or google for others) to get an idea of how to do this:
http://msdn.microsoft.com/en-us/library/0e743hdt.aspx