Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void PrintBooksByAuthorAndTotalPrice(Library library)
- {
- // group books in library by author, then order them descending, by their total price (using .Sum())
- // and finaly order them by author’s name lexicographically
- foreach (var book in library.Books
- .GroupBy(b => b.Autor)
- .OrderByDescending(x => x.Sum(p => p.Price))
- .ThenBy(k => k.Key))
- {
- Console.WriteLine($"{book.Key} -> {book.Sum(p => p.Price):f2}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement