CSharpFeeds - All your C# feeds in one place.

Sponsors

Sunday, June 17, 2007

Sort Generic List of T

by ssmith via Steve Smith's Blog on 6/17/2007 5:12:00 AM

Plenty of others have written about this so I'll keep it brief.  I needed to sort some objects based on a string property.  Some quick searching led me to this post which got me close to what I wanted.

 

My final code was this:

myThings.Sort(delegate(Thing x, Thing y) { return String.Compare(x.Name,y.Name); }); 

myThings is a List<Thing> collection.  String.Compare done in this fashion will sort them alphabetically - reverse its parameters to sort in reverse.

email it!bookmark it!digg it!

Original Post: Sort Generic List of T

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us