Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- class Program
- {
- static void Main()
- {
- int profCount = int.Parse(Console.ReadLine());
- Dictionary<string, int> precedence = new Dictionary<string, int>();
- string[] input = new string[profCount];
- //char[] factor = {'-'};
- for (int i = 0; i < profCount; i++)
- {
- input = Console.ReadLine().Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
- if (!precedence.ContainsKey(input[0]))
- {
- precedence.Add(input[0].Trim(), int.Parse(input[1]));
- }
- }
- int employeeCount = int.Parse(Console.ReadLine());
- List<Employees> workers = new List<Employees>();
- string[] data = new string[2];
- string[] subData = new string[2];
- //char[] subFactor = {' '};
- for (int i = 0; i < employeeCount; i++)
- {
- data = Console.ReadLine().Split(new string[] {" - "},StringSplitOptions.RemoveEmptyEntries);
- subData = data[0].Split(new string[] {" "},StringSplitOptions.RemoveEmptyEntries);
- Employees current = new Employees();
- current.firstName = subData[0].Trim();
- current.lastName = subData[1].Trim();
- current.profession = data[1].Trim();
- current.profPrecedence = precedence[current.profession];
- workers.Add(current);
- }
- //sort
- var sorted = workers.OrderByDescending(x => x.profPrecedence).ThenBy(x => x.lastName).ThenBy(x => x.firstName);
- //print
- foreach (Employees item in sorted)
- {
- Console.WriteLine("{0} {1}",item.firstName, item.lastName);
- }
- }
- }
- class Employees
- {
- public string profession;
- public string firstName;
- public string lastName;
- public int profPrecedence;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement