public void SortClient(object sender, ChoiceEventArgs e) { ConsoleKey keyBefor; ListSort.SortMenu(out keyBefor); switch (keyBefor) { case ConsoleKey.D1: case ConsoleKey.NumPad1: ListSort.SortByName(one); break; case ConsoleKey.D2: case ConsoleKey.NumPad2: ListSort.SortByLastName(one); break; case ConsoleKey.D3: case ConsoleKey.NumPad3: ListSort.SortByFhone(one); break; case ConsoleKey.D4: case ConsoleKey.NumPad4: ListSort.SortByadress(one); break; } Console.WriteLine("Sort Is done"); }
static public void SortByFhone(PhoneBook book) { ListSort.Sort(book, (client1, client2) => client1.foneNumber > client2.foneNumber); }
static public void SortByadress(PhoneBook book) { ListSort.Sort(book, (client1, client2) => string.Compare(client1.adress, client2.adress) < 0); }
static public void SortByLastName(PhoneBook book) { ListSort.Sort(book, (client1, client2) => string.Compare(client1.lastName, client2.lastName) < 0); }