Esempio n. 1
0
        public static void OrderAndTake(Dictionary <string, List <int> > wantedData, string comparison, int studentsToTake)
        {
            // Dictionary<string, List<int>> sortedResults = new Dictionary<string, List<int>>();

            comparison = comparison.ToLower();

            if (comparison.Equals("ascending"))
            {
                //sortedResults = GetSortedStudents(wantedData, studentsToTake, CompareInOrder);
                OutputWriter.PrintStudents(wantedData.OrderBy(x => x.Value.Sum())
                                           .Take(studentsToTake)
                                           .ToDictionary(pair => pair.Key, pair => pair.Value));
            }
            else if (comparison.Equals("descending"))
            {
                //sortedResults = GetSortedStudents(wantedData, studentsToTake, CompareDescendingOrder);
                OutputWriter.PrintStudents(wantedData.OrderByDescending(x => x.Value.Sum())
                                           .Take(studentsToTake)
                                           .ToDictionary(pair => pair.Key, pair => pair.Value));
            }
            else
            {
                OutputWriter.DisplayException(ExceptionMessages.InvalidComparisonQuery);
                return;
            }

            //foreach (KeyValuePair<string, List<int>> student in sortedResults)
            //{
            //    OutputWriter.PrintStudent(student);
            //}
        }