You can achieve this easily. let assume we have an object (class) called Item
as:
public class Item
{
public string Name { get; set; }
public string Description { get; set; }
public string Name2 { get; set; }
}
and this an example of a data collection
var items = new List<Item>
{
new Item {Name = "Test 1", Description = "Description 1"},
new Item {Name = "Test 2", Description = "Description 2"}
};
using the switch
condition like
IOrderedEnumerable<Item> orderedItems;
switch (selection)
{
case 1:
orderedItems = items.OrderBy(i => i.Name);
break;
case 2:
orderedItems = items.OrderBy(i => i.Description);
break;
default:
orderedItems = items.OrderBy(i => i.Name2);
break;
}