diff --git a/Lab3/Lab3/Lab3/Program.cs b/Lab3/Lab3/Lab3/Program.cs index 52cc432..70987ac 100644 --- a/Lab3/Lab3/Lab3/Program.cs +++ b/Lab3/Lab3/Lab3/Program.cs @@ -15,17 +15,17 @@ class Lab3 int[] amountOfWords = new int[textSplit.Length]; for (int i = 0; i < textSplit.Length; i++) { - string[] words = textSplit[i].Trim().Split(' '); + string[] words = textSplit[i].Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries); amountOfWords[i] = words.Length; } // створюємо Dictionary, де ключ - кількість слів у реченні, а значення - речення - Dictionary sentenceDictionary = new Dictionary(); + Dictionary sentenceDictionary = new Dictionary(); for (int i = 0; i < textSplit.Length; i++) { - sentenceDictionary.Add(amountOfWords[i], textSplit[i]); + sentenceDictionary.Add(textSplit[i],amountOfWords[i] ); } - var sortedDict = sentenceDictionary.OrderBy(x => x.Key).ToDictionary(x => x.Value, x => x.Key); + var sortedDict = sentenceDictionary.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); Console.WriteLine(String.Join(";", sortedDict.Keys));