public static void Print_using_orderby(GridSortOptions sort) { var temp = CommonCollections.IEGetAllCats(); temp = temp.OrderBy(sort.Column, sort.Direction); foreach (CommonCollections.Cat c in temp) { Console.WriteLine(PrintCats(c)); } Console.ReadKey(); }
public static void Sort_Ascending_Descending() { Console.WriteLine("Cats listed by name in ASCENDING Order:"); var temp = new GridSortOptions { Column = "Name", Direction = SortDirection.Ascending }; Print_using_orderby(temp); Console.WriteLine("Cats listed by name in DESCENDING Order:"); var temp2 = new GridSortOptions { Column = "Name", Direction = SortDirection.Descending }; Print_using_orderby(temp2); Console.WriteLine("Cats listed by Age in ASCENDING Order:"); var temp3 = new GridSortOptions { Column = "Age", Direction = SortDirection.Ascending }; Print_using_orderby(temp3); Console.WriteLine("Cats listed by Age in DESCENDING Order:"); var temp4 = new GridSortOptions { Column = "Age", Direction = SortDirection.Descending }; Print_using_orderby(temp4); }