Asp.net: Sort generic list with a delegate.

You can use a delegate to sort a generic list.

Example

 

GenericList ObjectItem = new GenericList ObjectItem()

GenericList.Sort(delegate(ObjectItem i1,ObjectItem i2)
{
 return i1.SortProperty.CompareTo(i2.SortProperty);
});


2 Replies to “Asp.net: Sort generic list with a delegate.”

  1. Its always good to learn tips like you share for blog posting. As I just started posting comments for blog and facing problem of lots of rejections. I think your suggestion would be helpful for me. I will let you know if its work for me too.
    Thanks and keep post such a informative blogs.

Leave a Reply

Your email address will not be published. Required fields are marked *