Proggraming Fundamentals / Tech Module
Приятели решавам една задача Population Counter до края на задачата съм , но немога да продължа с изпринтването на речниците ми , Collect-нал съм тоест събрал съм данните във 2 речника .Отдолу ще пусна кода и Искам да разбера как мога да взема Keyovete на единия речник и да се подредят в реда както са на друг речник , да и 2та са с еднакъв брой елементи , единия е със сортирани Keyove другия трябва да стане същия като първия , и другия ми въпрос е как да изпринтирам съдържанието на речника ми countryCity = new Dictionary<string, List<string>>(); като е със лист
var stopWatch = new Stopwatch();
            stopWatch.Start();
            var input = Console.ReadLine();
            var countryCity = new Dictionary<string, List<string>>();
            var cityPopulation = new Dictionary<string, int>();
            var countryTPopulation = new Dictionary<string, int>();
            
            var totalPop = 0;
            while (input!="report")
            {
                var split = input.Split('|').ToArray();
                var city = split[0];
                var country = split[1];
                var population = Int32.Parse(split[2]);
                cityPopulation[city] = population;
                countryTPopulation[country] = population;
                if (countryCity.ContainsKey(country))
                {
                    countryCity[country].Add(city);
                    if (countryCity[country].Count>1)
                    {
                        totalPop = cityPopulation.Values.Aggregate((a, b) => a + b);
                        countryTPopulation[country] = totalPop;
                    }
                }
                else
                {
                    countryCity.Add(country, new List<string>());
                    countryCity[country].Add(city);
                }
                
                
               
                input = Console.ReadLine();
            }
            countryTPopulation = countryTPopulation.OrderByDescending(p => p.Value).Take(5).ToDictionary(p =>p.Key,p =>p.Value);
            countryCity = countryCity.OrderByDescending(p => p.Value).Take(5).ToDictionary(p => p.Key, p => p.Value);
//да се довърши
stopWatch.Stop();
задачата-->https://imgur.com/a/fXxLD
Много благодаря ,че някой отговори . Доста насочливо, а тази задача май ще скоча на дълбокото с Dictionary <<string,Dictionary<string,int>>