Hi Burak,
I have demonstrated the simple way how you can acheive sorting of class objects. Below is the code
//Your Class
public class Address
{
public string City {set; get;}
public string State {set; get;}
}
// Your code class
public enum SortDirection { Ascending, Decending }
public void Sort<TKey>(ref List<Address> list,
Func<Address, TKey> sorter, SortDirection direction)
{
if (direction == SortDirection.Ascending)
list = list.OrderBy(sorter);
else
list = list.OrderByDescending(sorter);
}
//Now you can specify the field to sort when calling the Sort method.
Sort(address, e => e.City, SortDirection.Decending);