Sort Generic List of T
Date Published: 17 June 2007
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(<span class="kwrd">delegate</span>(Thing x, Thing y) { <span class="kwrd">return</span> String.Compare(x.Name,y.Name); });
myThings is a List
Tags - Browse all tags
Category - Browse all categories
About Ardalis
Software Architect
Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.