public override void Execute() { string[] data = this.Data; if (data.Length != 3) { throw new ArgumentException(this.Input); } string entityToDisplay = data[1]; string sortType = data[2]; if (entityToDisplay.Equals("students", StringComparison.OrdinalIgnoreCase)) { IComparer <Student> studentComparator = this.CreateStudentComparator(sortType); ISimpleOrderedBag <Student> list = this.repository.GetAllStudentsSorted(studentComparator); OutputWriter.WriteMessageOnNewLine(list.JointWith(Environment.NewLine)); } else if (entityToDisplay.Equals("courses", StringComparison.OrdinalIgnoreCase)) { IComparer <Course> courseComparator = this.CreateCourseComparator(sortType); ISimpleOrderedBag <Course> list = this.repository.GetAllCoursesSorted(courseComparator); OutputWriter.WriteMessageOnNewLine(list.JointWith(Environment.NewLine)); } else { throw new InvalidCommandException(this.Input); } }