Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03Articles2._0
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberOfArticles = int.Parse(Console.ReadLine());
- List<Article> articles = new List<Article>();
- for (int i = 1; i <= numberOfArticles; i++)
- {
- string[] currentArticle = Console.ReadLine().Split(", ");
- string title = currentArticle[0];
- string content = currentArticle[1];
- string author = currentArticle[2];
- articles.Add(new Article(title, content, author));
- }
- string inputCriteria = Console.ReadLine();
- if (inputCriteria == "title")
- {
- articles = articles.OrderBy(t => t.Title).ToList();
- }
- else if (inputCriteria == "content")
- {
- articles = articles.OrderBy(t => t.Content).ToList();
- }
- else if (inputCriteria == "author")
- {
- articles = articles.OrderBy(t => t.Author).ToList();
- }
- Console.WriteLine(articles.ToString());
- }
- }
- class Article
- {
- public string Title { get; set; }
- public string Content { get; set; }
- public string Author { get; set; }
- public Article(string title, string content, string author)
- {
- Title = title;
- Content = content;
- Author = author;
- }
- public override string ToString()
- {
- return $"{Title} - {Content}: {Author}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement