Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string ReplaceNoise(string input)
- {
- string[] noise = new string[] { "the", "an", "a" };
- foreach (string n in noise)
- {
- if (input.ToLower().StartsWith(n))
- {
- return input.Substring(n.Length).Trim();
- }
- }
- return input;
- }
- static void Main(string[] args)
- {
- List<Book> schools = new List<Book>{
- new Book{ ID=9, Title="The Nines"},
- new Book{ ID=6, Title="A Six Company Strategy"},
- new Book{ ID=3, Title="An Age of Three"},
- new Book{ ID=2, Title="Two's Company"},
- new Book{ ID=709, Title="The Sevens"}
- };
- //foreach (var item in schools.Select(x => new { NewTitle = ReplaceNoise(x.Title) }).OrderBy(n => n.NewTitle))
- foreach (var item in schools.OrderBy(n => ReplaceNoise(n.Title)))
- {
- Console.WriteLine(item.Title);
- }
- Console.ReadLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement