Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Articles2
- {
- class Program
- {
- public static void Main()
- {
- List<Article> articles = new List<Article>();
- int num = int.Parse(Console.ReadLine());
- for (int i = 0; i < num; i++)
- {
- string[] info = Console.ReadLine().Split(", ", StringSplitOptions.RemoveEmptyEntries).ToArray();
- Article article = new Article(info[0], info[1], info[2]);
- articles.Add(article);
- }
- string str = Console.ReadLine();
- articles.OrderByDescending(x => str == "title" ? x.Title : str == "content" ? x.Content : x.Author).ToList();
- Console.WriteLine(String.Join("\n", articles));
- }
- public class Article
- {
- public Article(string title, string content, string author)
- {
- Title = title;
- Content = content;
- Author = author;
- }
- public string Title { get; set; }
- public string Content { get; set; }
- public string Author { get; set; }
- public override string ToString()
- {
- return $"{Title} - {Content}: {Author}";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement