public async Task Run() { var people = await _personProvider.LoadPeople(); if (people == null) { Console.WriteLine("No data available."); return; } var filteredData = _aggregationService.Aggregate( people, owner => owner.Gender, pet => pet.Type == PetType.Cat, pet => pet.Name ); foreach (var entry in filteredData) { Console.WriteLine(entry.Key); foreach (var pet in entry.Value.OrderBy(p => p)) { Console.WriteLine($" * {pet}"); } } }