static void Main()
// Initialize a List of strings.
List<string> sampleList = new List<string>
// Send the List to the method.foreach (string s in SortByLength(sampleList))
static IEnumerable<string> SortByLength(IEnumerable<string> e)
// Use LINQ to sort the array received and return a copy.
var sorted = from s in e
orderby s.Length ascending
LINQ syntax. The C# language supports query expressions, and they have the "from" keyword. The example uses this syntax—it is the clearest to understand.
Other properties. You can use any property on objects as the sorting key, not just Length. For complex sorts, implementing IComparable may be a better option.