06. Courses / Associative Arrays - Exercise
Здравейте,
Имам проблем при сортирването накрая на програмата, ако може някой да предложи някакво решение,
условие(задача 6):https://softuni.bg/trainings/resources/officedocument/44281/exercise-problem-descriptions-csharp-fundamentals-september-2019/2438
Само това остава да се извърши: print the courses with their names and total registered users, ordered by the count of registered users in descending order. For each contest print the registered users ordered by name in ascending order
Това ми е кода махнах само сортирването във foreach че го бях много омазал :
using System;
using System.Collections.Generic;
using System.Linq;
namespace _06._Courses
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, List<string>> courseInfo = new Dictionary<string, List<string>>();
while (true)
{
string command = Console.ReadLine();
if(command == "end")
{
break;
}
string[] tokens = command.Split(" : ");
string course = tokens[0];
string student = tokens[1];
if (!courseInfo.ContainsKey(course))
{
courseInfo.Add(course, new List<string>());
courseInfo[course].Add(student);
}
else
{
courseInfo[course].Add(student);
}
}
foreach (var course in courseInfo)
{
Console.WriteLine($"{}: {}");
}
}
}
}
Благодаря, това много ми помогна