Search for unique books by genre using LINQ
C#
Medium
LINQ
Task «Search for unique books by genre using LINQ»
Write a C# program that reads a list of books (title and genre separated by a comma) and uses LINQ to find all unique genres. For each genre, output the number of books, sorted in descending order of count. If the count is the same, sort alphabetically by genre. Input ends with an empty line. Output the result in the format: "Genre: count".
Input Format
Strings of the form "Title,Genre" up to an empty line.
Output Format
Strings of the form "Genre: count", sorted in descending order of count, and in alphabetical order when counts are equal.
Examples
Example 1
INPUT
Алиса в Стране чудес,Сказка
Гарри Поттер,Фэнтези
Властелин колец,Фэнтези
OUTPUT
Фэнтези: 2
Сказка: 1
Example 2
INPUT
5
add task1 3
add task2 1
add task3 2
highest
get task2
OUTPUT
main.cs