Sort list <T> inside subclass with LINQ
I know that I can sort a list doing something like this
var result = List<T>.OrderBy(value => value.property);
But I will say that I have something like this
class Stock
{
public Guid ID { get; set; }
public string Description { get; set; }
}
class StockList : List<Stock>
{
public enum SomeEnum
{
SomeOtherValue = 0,
SomeOtherOtherValue
}
//What if I want method like this using LINQ?
public void Sort(SomeEnum sortBy)
{
switch (sortBy)
{
case SomeValue.SomeOtherOtherValue:
//Sort one way
break;
case SomeValue.SomeOtherValue:
//Sort another
break;
}
}
}
this.OrderBy()(and I suppose other LINQ extensions) return an OrderedCollection and don't seem to affect the original. So, I guess I'm wrong?
+3