My Code looks like this :
Collection optionInfoCollection = ....
List optionInfoList = new List
If you just want Sort() to work, then you'll need to implement IComparable or IComparable in the class.
If you don't mind creating a new list, you can use the OrderBy/ToList LINQ extension methods. If you want to sort the existing list with simpler syntax, you can add a few extension methods, enabling:
list.Sort(item => item.Name);
For example:
public static void Sort(
this List source,
Func selector)
{
var comparer = Comparer.Default;
source.Sort((x, y) => comparer.Compare(selector(x), selector(y)));
}
public static void SortDescending(
this List source,
Func selector)
{
var comparer = Comparer.Default;
source.Sort((x, y) => comparer.Compare(selector(y), selector(x)));
}